❔ EF modelbuilder for table without primary keys
I have a simple table
JobUnitTag
with two fields, Guid JobUnit
and Guid JobTag
.
I tried to build it like this modelBuilder.Entity<JobUnitTag>()
, but it does not work because it requires primary key. I tried modelBuilder.Entity<PlanJobUnitTag>().HasNoKey();
and the error was the same.
Then i gave my JobUnit
a [Key] identifier (even tho its not primary key), and it works.
However, I occur a problem when I try to insert a new entry with the same JobUnit
value. (I assume its because of the [Key].
Any idea how could I bypass that?3 Replies