问题描述
我安装VS SP1和实体框架发挥各地。
I installed VS SP1 and played around with Entity Framework.
我是从现有的数据库创建的模式,并尝试了一些基本操作。
I created a schema from an existing database and tried some basic operations.
大多数的很顺利,除了数据库模式的更新。
Most of it went well, except the database schema update.
我的每一个基本方式更改的数据库:
I changed the database in every basic way:
- 添加了一个新表
- 删除表
- 添加了一个新的列到现有的表
- 从现有表中删除列
- 改变现有列的类型
前三个得很顺利,但类型的变化和列删除并没有跟随数据库的变化。
The first three went well, but the type change and the column deletion did not followed the database changes.
有没有什么办法,使从设计师的工作?抑或是不支持的时刻?我没有找到任何相关的材料还,但仍在寻找。
Is there any way to make is work from the designer? Or is it not supported at the moment? I didn't find any related material yet, but still searching.
推荐答案
我猜想,可能是那些没有发生,因为他们会打破建立现有code,但是这只是我的猜测而已。
I would guess that possibly those don't happen because they would break the build for existing code, but that's just a guess on my part.
下面是我的逻辑:
首先,EF应该是大于1:1表映射,所以它很可能只是因为你是从表A中删除列并不意味着该实体,不应该有一个属性说明。你可能会认为性只是映射到另一个表。
First, EF is supposed to be more than 1:1 table mapping, so it's quite possible that just because you are deleting a column from table A doesn't mean that for that entity, there shouldn't be a property Description. You might just map that property to another table.
其次,改变类型可能只是突破的基础之上。这是唯一的理由存在。
Second, changing a type could just break builds. that's the only rationale there.
这篇关于在实体框架更新数据库架构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!