Reputation: 11350
I am current running EF 4.3.1 which was recently upgraded from 4.1, using a database first model. I also have my model and objects spread across different assemblies.
As I'm developing however, I'm finding the entity framework almost impossible to live with, because despite having the option "update model from database", seldom can I do so without causing the designer to fire up errors.
If I add an index to a table, create a fk relationship, there's a good chance that the designer will show a 'object null reference exception' when I try do do anything with the database afterwards. To make it even harder, the error message is exactly that vague, not pointing to what it actually could be.
I have asked a question elsewhere and the response I got back was to recreate the edmx. Surely not when I have 60 to 80 entities?
I can't believe that I'm the only one with the issue, and i can't believe any developer could live with the situation, but I can't find information anywhere as to what the issue is - if in fact its not 'by design'.
Can anyone help?
Upvotes: 2
Views: 1369
Reputation: 11350
The reason for the crash is due to the de-sync'd relationship between the edmx and the dbcontext.
When changes, or even refresh is applied to the edmx you MUST run the custom tool update before exiting the project. Failure to do this will result in a corrupt edmx., which I have yet not managed to fix without restoring/recreating it.
Whilst this is in your hands most of the time, obviously there are occasions when this is outside of your control and should be something managed by the framework rather than depend on your ability to remember and the will of god. Hopefully longer term this will be included in the framework.
Upvotes: 1