使用Entity Framework时保持与数据库的并发性
问题描述:
我刚刚开始使用Entity Framework(版本6)的教程,并在我的一个小项目中使用它。
我脑海里浮现的问题很少......模型是否在实体框架是自动更新的?如果我正在更改数据库中任何列的数据类型或添加新列...如果在数据库中更改存储过程的定义...如果它也将反映在模型中该怎么办。
由于我必须向客户提供我的解决方案,我需要清楚这些问题。
I have just started with tutorials on Entity Framework(version 6) and also used it in one of my small project.
There are few questions lingering in my mind...does the model in entity framework is auto updated? what if i am changing datatype for any column in database or adding new column...also what if the definition of stored procedure is changed in database...will it be reflected in model as well.
As i have to provide my solution to client, i need to get clear with these questions.
答
嗨Sneha,
您的问题是,实体框架中的模型是否自动更新?
答案是否定,如果您想根据数据库然后执行以下步骤: -
转到model.edmx右键单击然后选择 - >从数据库更新模型,它将打开一个向导,您可以选择要更新到模型的数据库实体,即您的表格,程序等。
- >选择后 - >点击向导中的完成按钮,它将根据您选择的项目自动更新您的模型。
谢谢,
Mukesh
Hi Sneha,
your question is , does the model in entity framework is auto updated?
Answer is No, And If you want to update your model according to the database then do following steps:-
Go to model.edmx right click then select--> update model from database , it will open one wizard in that you can select your database entities that you want to update to your model i.e. your table , procedures etc.
--> after selecting --> click on finish button in the wizard it will automatically update your model according to your selected items.
Thanks,
Mukesh