如何从特定迁移中生成代码优先迁移脚本? [英] How to generate code first migration script from a specific migration?

查看:62
本文介绍了如何从特定迁移中生成代码优先迁移脚本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个生产和开发数据库。现在,我想基于特定的迁移生成一个sql脚本。当我输入生成脚本的行时,出现以下错误:

I have a production and a development database. Now I want to generate a sql script based on a specific migration. When I enter the line to generate the script I get this error:

'201608121243147_AutomaticMigration'不是有效的迁移。编写脚本之间的升级脚本时,必须同时对源迁移和目标迁移使用显式迁移。

我使用的命令如下:

更新数据库-脚本-SourceMigration:201608121243147_AutomaticMigration -TargetMigration:201608281101542_AutomaticMigration

当我执行命令 get-migrations 时,我可以看到列表中有这两个迁移。目标迁移也是我的最新迁移,但是当我忽略此参数时,我会遇到相同的异常。

When I execute the command get-migrations I can see those two migrations are in the list. The target migration is also my latest migration, but when I omit this parameter I get the same exception.

我在做什么错?我该怎么做才能解决此问题?

What am i doing wrong? What do I have to do to fix this?

推荐答案

这对我有用。

Update-DataBase -Script -SourceMigration:"Version1" -TargetMIgration:"Version2"

关于
阿卜杜勒

Regards Abdul

这篇关于如何从特定迁移中生成代码优先迁移脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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