griegs
griegs

Reputation: 22770

The table does not have a primary key defined error

I have two tables that are basically link tables.

So one looks like this;

QueueId
TaskId

the two columns link to a Queues table and a Tasks table.

There is no primary key and i don't believe I need one.

I so try to import it into my .EDMX and I get the warning that

the table does not have a primary key defined but that it's been inferred as a read only table.

Also, the table doesn't show up in the Diagram and there is no model created for it.

I added a primary key and then got errors in my code.

I deleted all tables and did it all again and still the same thing happens with this one table.

The second table that is virtually identical has the same error but does appear in the diagram.

How do I get the first table to show in the diagram and not be read only because I need to delete the associations from time to time.

Thanks

Upvotes: 1

Views: 978

Answers (1)

Dmitry Rotay
Dmitry Rotay

Reputation: 3280

Entity Framework doesn't need association table in the model to work with it.

There should be two navigation properties on either side of the relation - Task has ICollection<Queue> and Queue has ICollection<Task>. To remove association between specific task and queue you either find queue and remove that thask from it's collection, or do the reverse.

Upvotes: 2

Related Questions