1

Scenario:

Database first. I have a table with no primary key set and I'm trying to make an update with Entity Framework.

This is the error message I keep getting:

The property 'inactive_date' is part of the object's key information and cannot be modified. 

If I set the fields 'Entity Key' value to 'false' I get this error messge:

Modifications to tables where a primary key column has property 'StoreGeneratedPattern' set to 'Computed' are not supported. Use 'Identity' pattern instead. Key column: 'timestamp'. Table: 'plat12Model.Store.glchart'.

Would this be corrected if I created a primary key? Can I set a primary key in my code rather than on the database?

1 Answer 1

1

By default, EF will make tables without primary keys and views into read-only classes where every field is part of the composite key. You can modify the conceptual model to reflect the actual behavior as long as you retain a key value that EF will use for object tracking. As the error message states, you also need to make the columns no longer computed in order to update them as well.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you. I ended up creating PKs in the tables.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.