The mistake is completely meaningless to me, and this item is driving me crazy:
EntitySet "TableB" cannot be updated because it includes a DefiningQuery and the element lacks the necessary elements to support the requested action.
My tables are set up as follows:
TableA int idA (identity, primary key) ... TableB int idA (FK for TableA.idA) int val
The SQL server does not have a primary key specified for TableB. The table and association were imported into the Entity Framework, and both fields were designated as keys. But if I attempt to insert data into the table, it will print that error!
What's the issue?
Edit: The answer, as Alex had indicated, was this:
Since I thought it was OK that both columns were included in the key, I left it exactly as it was.
In any case, a table without a PrimaryKey is handled as a view.
Additionally, views may be found in the StorageModelEntitySet[n]DefiningQuery element of the EDMX file (open it in an XML editor to check).
The Entity becomes read-only when you have a DefiningQuery until you provide modification functions. Each of the three changes functions (also known as stored procedures), one for insert, update, and delete, is required.
However, you have two choices:
Modify the key definition:
In your situation, I advise (1).
Just give the table a main key. I'm done now. Issue is resolved.
ALTER TABLE <TABLE_NAME> ADD CONSTRAINT <CONSTRAINT_NAME> PRIMARY KEY(<COLUMN_NAME>)