使用EF4迁移工具与模型,第一种方法

编程入门 行业动态 更新时间:2024-10-23 11:29:39
本文介绍了使用EF4迁移工具与模型,第一种方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

EF迁移实用程序首先使用code时,看起来相当不错。

EF migration utility seems quite nice when using code first.

href="www.$c$ctunnel/blog/post/111/introduction-to-entity-framework-43-migrations--part-ii">this博客文章,我想在我的项目中,我们使用的模型首先设置它。当运行时启用-迁移命令时,我得到以下错误:

Based on this blog post, I tried setting it in my project where we use model-first. When running Enable-Migrations command, I get the following error:

创建DbModelBuilder或写EDMX从的DbContext使用数据库优先或模型首先不支持创建。 EDMX只能从一个code首先的DbContext创建,而无需使用现有DbCompiledModel获得

Creating a DbModelBuilder or writing the EDMX from a DbContext created using Database First or Model First is not supported. EDMX can only be obtained from a Code First DbContext created without using an existing DbCompiledModel.

有什么办法解决它,所以我们可以使用EF迁移而无需切换到code-第一?

Is there any way around it so we can use the EF migration without switching to code-first?

推荐答案

我对你如何能做到这一点不完整的博客条目。不知道是否会满足您的需求,但似乎是唯一可用的方法为止。

I have an incomplete blog entry on how you could do this. Not sure if it will fit your need, but seems to be the only method available so far.

基本上你使用自定义T4为模型生成DbMigrationsConfiguration和的DbContext,你不需要运行Enable-迁移的。只需运行加入迁移和更新,数据库的软件包管理器控制台。

Basically you use custom t4 to generate DbMigrationsConfiguration and DbContext from your model and you don't need to run Enable-Migration at all. Simply run Add-Migration and Update-Database in the Package Manager Console.

blog.amusedia/ 2012/08 /实体架构迁移与 - model.html

我会更新博客条目,T4,使之更人性化版本。

I will be update the blog entry and t4 to make it more user friendly later.

更多推荐

使用EF4迁移工具与模型,第一种方法

本文发布于:2023-05-29 23:11:25,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/355117.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:种方法   模型   工具

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!