EntityFramework classes updated after upgrade?

I changed my database model so that one of the foreign keys of the table accepts NULL values. Subsequently, I went to my .edmx file and did "Update model from database ...", and after saving all my class files representing tables, it was automatically deleted.

If I revert my changes to the database and save my .edmx , the classes will reappear. But I really want this foreign key to be able to take zeros. What could be the reason for this?

+3
source share
2 answers

I managed to solve the problem by recreating the edmx model, but yes, there was some error in the error list. They pointed out some flaws that no longer work.

0
source

For everyone who may have this problem and who does not want to recreate their EDMX:

I had a similar problem, which was repeated several times, which I was able to fix by filtering the list of errors using "Assembly Only".

As soon as I did this, I discovered a number of errors regarding multiplicity conflicts that I could solve by going to the Model Browser in the Association and changing the values ​​of End1 and End2 Multiplicity (if applicable).

In my case, deleting the ability of the FK column to be null (in the database) led to the fact that the constructor of entities could not preserve the multiplicity 1..1. Switching to 0..1 fixed the problem.

+7
source

Source: https://habr.com/ru/post/951323/


All Articles