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迁移工具与模型,第一种方法
发布评论