Puppy
Puppy

Reputation: 147056

LINQ- inserting into conjoining tables

I've got a conjunction table, which is a one to many relationship. My LINQ code will not insert into this table because it has no primary key, even though the table is composed of just foreign keys. In addition, when I try to save the relationship for one of my foreign keys, it says that the ALTER_TABLE statement conflicts with the FOREIGN_KEY constraint. But I've checked all through both of the tables in question and there is no ALTER_TABLE anywhere.

How can I make changes that will allow me to insert into my conjunction table?

Upvotes: 0

Views: 303

Answers (1)

ctorx
ctorx

Reputation: 6951

Try creating a primary key on the table, that is a composite key of the foreign key columns. LINQ-to-SQL should like that a lot better. It will allow you to keep your current structure but provide a key that LINQ-to-SQL can use.

Upvotes: 2

Related Questions