简体   繁体   English

我可以从 edmx model 更新数据库表吗?

[英]I can update database table from edmx model?

Is possible update database table from edmx model, for example if I create a new field in edmx diagram to a table, I want update corresponding mapped table in database adding this new field... in visual studio menu I find the voice "update model from database" and "create database from model", but I not find "update database from model"...是否可以从 edmx model 更新数据库表,例如,如果我在 edmx 图表中创建一个新字段到一个表,我想在数据库中更新相应的映射表,添加这个新字段...在 Visual Studio 菜单中我找到语音“更新 model从数据库”和“从模型创建数据库”,但我没有找到“从模型更新数据库”...

In the EF EDMX "Model-First" workflow you always generate a full database DDL script, and for incremental changes use a schema-compare tool like SSDT to create the change script.在 EF EDMX“模型优先”工作流程中,您始终会生成完整的数据库 DDL 脚本,对于增量更改,请使用 SSDT 等模式比较工具来创建更改脚本。

See eg https://docs.microsoft.com/en-us/ef/ef6/modeling/designer/workflows/model-first#5-dealing-with-model-changes参见例如https://docs.microsoft.com/en-us/ef/ef6/modeling/designer/workflows/model-first#5-dealing-with-model-changes

It's not a very popular or useful workflow, and the tooling for incremental updates was just never built.这不是一个非常流行或有用的工作流程,而且从未构建过用于增量更新的工具。 The vast majority of EDMX users do a database-first workflow with no customization of the EDMX.绝大多数EDMX 用户在没有自定义 EDMX 的情况下执行数据库优先的工作流程。

But you should really stop using EDMX.但是你真的应该停止使用 EDMX。 The graphical designer seems simpler to begin with, but using code-based mapping is simpler in the long run.图形设计器一开始似乎更简单,但从长远来看,使用基于代码的映射更简单。

I don't believe Edmx (database fist) works that way, at least, out of the box.我不相信 Edmx(数据库拳头)以这种方式工作,至少,开箱即用。 You need to use code first, and enable migrations.您需要先使用代码,然后启用迁移。 Edmx is nothing more than mapping to your data, that doesn't tie into migrations. Edmx 只不过是映射到您的数据,与迁移无关。 I believe there is a way to auto-generate your code first as well using visual studio...just like the Edmx.我相信有一种方法可以首先使用 Visual Studio 自动生成代码……就像 Edmx 一样。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM