1

I have a Warning model, with which I insert warnings into LiteDB. I want to be able to insert warnings with the same UserId, like in SQLite, but I get this error:

Cannot insert duplicate key in unique index '_id'.
The duplicate value is '{"$numberLong":"483817273803538450"}'.

Warning Model

[BsonId(false)]
public ulong UserId { get; set; }
public string Reason { get; set; }
public string Issuer { get; set; }
public int Status { get; set; }

Is there anything I can do, to insert a warning with the same UserId multiple times?

Asger
  • 3,822
  • 3
  • 12
  • 37

1 Answers1

1

Your UserId could be a primary key, or an index is created on that column which is preventing you to add duplicate values.

As primary key have default Unique Index implemented, so you wouldn't be able to insert duplicate values.

Edit your table structure and remove primary key from your table, Hope so it will resolve your problem of putting duplicate UserId in a table.

Hammad Sajid
  • 312
  • 1
  • 3
  • 14