VS 2012 - EF 5.0 - 从数据库更新模型 - 不提取表更改 [英] VS 2012 - EF 5.0 - Update Model from Database - Not picking up table changes

查看:574
本文介绍了VS 2012 - EF 5.0 - 从数据库更新模型 - 不提取表更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Visual Studio 2010 EF 4中,我可以在数据库表中添加一个新列,然后单击我的.edmx上的从数据库更新模型,所有的都在世界上很好。

In Visual Studio 2010 EF 4, I could add a new column to a database table, then click 'Update Model from Database' on my .edmx and all was good in the world.

在Visual Studio 2012 EF 5中,我更改了一个表,然后单击从数据库更新模型,并且它不再接收到各个表的更改。

In Visual Studio 2012 EF 5, I alter a table, and then click 'Update Model from Database' and it does not pick up the changes to individual tables anymore.

我是否缺少某些东西?或者这是VS2012的新功能?

Am I missing something ... or is this a new 'feature' of VS2012?

更新
唯一的方法,我可以得到一个添加列反映在.EDMX文件的表是删除表,然后'从数据库更新模型',它会拾起添加的列。然而,它把附加的表放在左边,我必须把它移回原位。没有 biggie 只是一个麻烦。

推荐答案

有一个EF模型和它是如何在数据库中加下划线。当您从数据库更新模型时,如果实体/表已经导入到数据模型中,那么您将刷新该实体。此过程不会自动将您的数据库模式映射到现有数据模型,但您可以向EF模型中的实体添加一个属性,然后将属性映射到数据库列(这正是EF在您自动执行时删除和更新正常)。

There is a difference between having an EF Model and how it is underlined in your database. When you "Update model from database", if the entity/table is already imported into your data model then you will be refreshing the entity. This process will not automatically map your database schema to your existing data model, you can however add a property to the entity in your EF model, and then map the property to the database column (this is exactly what EF does for you automatically when you delete and update normally).

首先删除实体时,更新EF知道表/实体尚未导入,因此将映射所有数据库列为您自动。

When you delete the entity first, then update EF knows that the table/entity has not been imported before and so will map all of the database columns automatically for you.

总而言之,您不需要删除该实体,但对简单实体来说可以更容易。

In summary, you don't HAVE to delete the entity, but it can be easier to do so for simple entities.

这篇关于VS 2012 - EF 5.0 - 从数据库更新模型 - 不提取表更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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