实体框架:当数据库更改时,如何刷新模型? [英] Entity Framework : How do you refresh the model when the db changes?

查看:97
本文介绍了实体框架:当数据库更改时,如何刷新模型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果您从数据库中构建edmx文件,然后数据库更改,那么您如何使模型获取更改?

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 can you detect changes?

我看到一个提到更新你的模型的文章。鼠标在edmx文件上的命令,但我看不到它。

I see a post mentioning a "Update Your Model" rt. mouse command on the edmx file, but I dont see it.

Updating your edmx to reflect changes made in your db (.net linq-to-entities)

我刚刚开始。

推荐答案

你在看设计师或代码视图?您可以通过右键单击EDMX文件并选择 Open With - >来强制设计者打开。 ADO.NET实体数据模型设计器

Are you looking at the designer or code view? You can force the designer to open by right clicking on your EDMX file and selecting Open With -> ADO.NET Entity Data Model Designer

右键单击EDMX设计器的设计器表面,然后单击更新模型从数据库...

Right click on the designer surface of the EDMX designer and click Update Model From Database...

默认情况下刷新所有实体,只有在您选择新实体时,才会添加新实体。

All entities are refreshed by default, new entities are only added if you select them.

编辑:
如果没有刷新,

If it is not refreshing well.


  • 在EDMX设计器中选择所有表格和视图。

  • 删除它们。

  • 然后,从数据库更新模型

  • Select all the tables and view-s in the EDMX designer.
  • Delete them.
  • Then, update model from database

这篇关于实体框架:当数据库更改时,如何刷新模型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆