Entity Framework - Update Model From Database… - no update happens!

前端 未结 1 635
深忆病人
深忆病人 2021-02-07 11:44

I have a table in my DB called CompanyDetails. It has a column called CharacterID varchar(255). I just changed it from a NOT NULL column

相关标签:
1条回答
  • 2021-02-07 12:33

    The entity framework uses an XML file (the edmx) to specify the database scheme and mapping. When you click "update model from database" it is this edmx file that is updated.

    Next, when you compile your app, this edmx file is parsed and the backing classes you are looking at are generated, so if you want to see the change reflected in the backing classes you need to update the model, and then recompile.

    Finally, you also have to remember that the edmx contains 3 things.

    1. The database/storage scheme (SSDL)
    2. The conceptual model (CSDL)
    3. The mapping between conceptual and storage (MSL)

    Updating the database and clicking "update" will update the SSDL but won't necessarily make the required changes automatically to the conceptual model, you may need to open up the edmx is the designer and check the properties on the field. (It is entirely possible to have a nullable database field mapped to a non-nullable conceptual field, but obviously in this case that isn't what you want).

    0 讨论(0)
提交回复
热议问题