当我在4.0中构建它时,更新我的EF模型以使用4.1 [英] Updating my EF model to use 4.1 when I built it in 4.0
问题描述
谢谢
您可以将DbContext与您的EDMX型号一起使用。安装EFv4.1后,您应该可以使用新的T4模板:DbContext生成器。这将使您的EDMX并为您创建从 DbContext
和所有POCO实体派生的上下文。 这里你有演练。
但是如果你想切换到 DbContext
只是因为 DbContext.Entry.State
你不必。 EFV4有一个类似的机制:
context.ObjectStateManager.ChangeObjectState(entity,EntityState.Modified);
这里是如何更新EFv4中的实体的完整说明。
I built my EF Model in EF 4.0, and then installed the 4.1 upgrade that includes the new DBContext interface. How do I update my model so that it uses the 4.1 features going forward?
Thank You
You can use DbContext with your EDMX model. After installing EFv4.1 you should have new T4 template available: DbContext generator. This will take your EDMX and create context derived from DbContext
and all POCO entities for you. Here you have walkthrough.
But if you want to switch to DbContext
just because of DbContext.Entry.State
you don't have to. EFv4 has a similar mechanism:
context.ObjectStateManager.ChangeObjectState(entity, EntityState.Modified);
Here is the full description how to update an entity in EFv4.
这篇关于当我在4.0中构建它时,更新我的EF模型以使用4.1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!