使用实体框架模型第一种方法迁移 [英] Migration using model first approach in entity framework

查看:110
本文介绍了使用实体框架模型第一种方法迁移的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经安装在我所采取的模式第一方法,因为它为我做更多的逻辑意义上的系统。现在,当连我都在模型中的一些变化目前我做的是 -

I have setup a system where I have taken the model first approach as it made more logical sense for me. Now when even I have some changes in the model currently what I do is -


  1. 使用的从模型生成数据库实体框架的功能。我创建了一个虚拟的数据库和应用这些脚本。这将删除我的所有数据和表第一,然后更新与由实体框架生成的最新SQL文件数据库中。

  2. 现在,我使用 Visual Studio的架构比较的功能,并产生迁移脚本为我的本地数据库,也为其中之一就是在生产中。

  3. 我手动经过脚本和验证。一旦做到这一点我在生产实例运行迁移脚本。

  1. Use the Generate database from model feature of entity framework. I create a dummy database and apply those scripts. which deletes all my data and tables first and then updates the database with the latest sql file which is generated by entity framework.
  2. Now I use the Visual Studio's schema compare feature and generate migration scripts for my local database and also for the one which is in production.
  3. I go through the scripts manually and verify them. Once that is done I run the migration scripts on the production instances.

:主要的问题是,真的是单调乏味的,因为我从我的本地系统去做,连接到我的督促数据库非常缓慢,有时我的视觉工作室也崩溃。是否有一个更清洁的方式来做到这一点?这是更自动化,这样我的笔记本电脑是不是在生产实例数据库迁移?

Question : The main problem is that is really tedious and since I do it from my local system, connecting to my prod databases is very slow and sometimes my visual studio also crashes. Is there a more cleaner approach to do this? Which is more automated such that my laptop is not really responsible for the database migrations on the production instances?

推荐答案

您可以尝试的数据库迁移配电板 - 它允许创建更改脚本,而不是完整的数据库脚本,但背后确实像你一样用手相同的过程。问题是,提及<一href=\"http://data.uservoice.com/forums/72025-entity-framework-feature-suggestions/suggestions/3065564-ef5-model-first-genrate-db-update-script\"相对=nofollow>工具不能与EF5 工作。

You can try Database Migration Power Pack - it allows creating change scripts instead of full database scripts but on behind it does the same procedure as you did by hand. The problem is that mentioned tool will not work with EF5.

不幸的是<一个href=\"http://blogs.msdn.com/b/adonet/archive/2012/02/09/ef-4-3-automatic-migrations-walkthrough.aspx\"相对=nofollow> EF迁移目前不支持通过EDMX创建的模型。迁移支持目前只有code第一种方法。

Unfortunately EF migrations currently don't support models created through EDMX. Migrations support only code first approach at the moment.

这篇关于使用实体框架模型第一种方法迁移的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆