是否可以在 Migrator .NET 迁移中使用 EF codefirst 数据库初始化程序?
我正在使用 Migrator.NET 来管理生产环境中的架构更改。因为我一直在使用 EF 代码优先,所以对数据库的所有开发都是增量到代码优先类的,并且没有对项目应用任何迁移。
但是,我希望能够在项目进入生产环境后开始使用迁移。作为基线“向上”迁移,我想使用 code-first 的数据库初始值设定项来创建数据库并使用默认数据进行填充。但是,我遇到了问题,因为 EF 上下文类和 EF 初始值设定项的包装类位于 .NET 4 中,而迁移器 .NET 使用 .NET 2。
运行迁移器控制台应用程序时,我收到“此程序集是由比当前加载的运行时更新的运行时构建...”
我对此是否有太多期望?我可以使用 OSQL 并在服务器上创建 SQL 脚本,但如果这能像在开发环境中那样工作那就太好了。
I'm using Migrator.NET to manage schema changes on our production environment. Because I've been using EF code-first, all development to the database has been incremental to the code-first classes and no migrations have been applied to the project.
However, I'd like to be able to start using migrations once the project is in a production environment. As the baseline 'up' migration, I'd like to use code-first's database initializer to create the database and prime with default data. However, I'm having problems because the EF context classes and my wrapper classes for EF initializers are in .NET 4, whereas migrator .NET is using .NET 2.
When running the migrator console app, I'm getting 'This assembly is built by runtime newer than the currently loaded runtime...'
Am I expecting to much for this to work? I could use OSQL and create the SQL script on the server, but it would be nice if this worked just as it does in the development environment.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
唔。诡异的。即使 migratordotnet 二进制文件位于 .NET 2 中,您也应该能够使用它。我参与了一个项目,我们就是这么做的。如果架构不存在,我们使用 EF Code First 自动生成架构,否则我们将运行到现有架构的迁移(我们在仍处于开发阶段时就开始创建迁移步骤)。
Hmm. Weird. Even if the migratordotnet binary is in .NET 2 you should be able to use it. I worked on a project where we did just this. We used EF Code First to automatically generate the schema if it didn't exist, otherwise we would run the migrations to the existing one (we started creating the migration steps while still in the dev phase).