How to update an entity structure

I am updating my Entity Framework by simply right-clicking and clicking on “update model from database”. I usually go to the Add tab, and then click on the tables and click Finish. Sometimes I also use the "update". What are the differences between the two? and also when I update or add sometimes that the object crashes or stores some of the old information in the cache, how can I just make the entity match my database and clear any of the old cached things.

+3
source share
3 answers

He does not clean old objects. You must delete them yourself. On the plus side, Visual Studio will give you a compilation error stating that coloumn or two are not displayed. An entity infrastructure tool is more of a code generator. It generates classes based on the structure of your database, as opposed to database bindings for structure information.

+3
source

Yes you are right. The designer is a little buggy and doesn’t do very well with some circuit changes. Typically, when I add a table to the database, I start Update model from databaseand select the table in the tab Add. Works great. If I add a field to an existing table, I will do Update modeland Refresh. It works well.

( ), EF ( , , , ). , Update model from database Add.

, (, ), .

+5

, , , , CSDL MSL, , . CSDL - , , MSL - .

Believe me, this is a big step forward compared to Linq-to-sql, where there was no update, and you always had to delete everything, including your changes, when you want to update your model. If you made a lot of changes, you can always delete your entity in the EF designer. The EF designer offers the choice to upgrade or recreate (by deleting the old one).

+1
source

All Articles