Entity Framework : How do you refresh the model when the db changes?

前端 未结 9 956
囚心锁ツ
囚心锁ツ 2020-12-01 01:56

If you build the edmx file from the database and then the db changes, how do you get the model to pick up the change?

Do you delete the whole model and regenerate or

9条回答
  •  不知归路
    2020-12-01 02:09

    This might help you guys.(I've applied this to my Projects)

    Here's the 3 easy steps.

    1. Go to your Solution Explorer. Look for .edmx file (Usually found on root level)
    2. Open that .edmx file, a Model Diagram window appears. Right click anywhere on that window and select "Update Model from Database". An Update Wizard window appears. Click Finish to update your model.
    3. Save that .edmx file.

    That's it. It will sync/refresh your Model base on the changes on your database.

    For detailed instructions. Please visit the link below.

    EF Database First with ASP.NET MVC: Changing the Database and updating its model.

提交回复
热议问题