4

If any changes have made on the datatype or constraints(e.g. not null - null) of a particular column in table and performing Update model from database (Refresh a particular table) in entity framework is not updating the entity model.

Each time I have to delete and re-create the table manually.

Is this only solution? or any other best way to do this?

1
  • are you using migrations? Commented Mar 13, 2014 at 8:21

2 Answers 2

9

delete the applicable table(s) from your model, than select Update model from database, EF usually only checks for new fields, not changes to existing fields.

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

4 Comments

This answer is probably correct for most cases of this error.
What if I add a new table in database? Then your solution will not work!
@MahmoodJenami did you test this before you made this comment? can you say with 100% certainty that my solution will not work?
Yeah, That was exactly my case.
1

Check if the new updated/created table in the database contains an identity key column (like an ID column). Entity Framework is especially sensitive when working with tables that don't represent uniqueness in their records.

Comments

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.