我可以首先使用EF代码和.net核心生成迁移脚本吗

编程入门 行业动态 更新时间:2024-10-28 09:25:00
本文介绍了我可以首先使用EF代码和核心生成迁移脚本吗的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在使用.Net Core构建MVC应用程序,并且需要生成迁移脚本。

I'm building a MVC application with .Net Core and I need to generate the script of a migration.

对于EF6,我确实运行了命令

With EF6 I did run the command

update-database -script

,但是当我尝试对 Core做同样操作时,抛出下一个异常:

but when I try to do the same with Core is throwing the next exception:

Update-Database:A找不到与参数名称'script'匹配的参数

Update-Database : A parameter cannot be found that matches parameter name 'script'

您是否知道EF7是否等效?

Do you know if there is an equivalent for EF7?

推荐答案

按照 EF文档,则可以使用脚本迁移命令。

As per EF documentation you can use Script-Migration command.

如果只想编写所有迁移的脚本,则可以像这样从Package Manager控制台中调用它。如果您只想编写上一次迁移的更改脚本,则可以这样称呼:

If you want to just script all the migrations you can simply call it from Package Manager console like that. If you want to just script the changes from the last migration you can call it like this:

Script-Migration -From <PreviousMigration> -To <LastMigration>

请务必检查文档,该命令还有更多选项。

Be sure to check the docs, there're a few more options to the command.

更多推荐

我可以首先使用EF代码和.net核心生成迁移脚本吗

本文发布于:2023-11-16 07:12:05,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1602116.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:脚本   核心   代码   EF   net

发布评论

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

>www.elefans.com

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