EF中的Add-Migration中StartupProjectName参数的用途是什么 [英] What's the purpose of StartupProjectName parameter in Add-Migration in EF

查看:182
本文介绍了EF中的Add-Migration中StartupProjectName参数的用途是什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

据我了解 Add-Migration 在做什么,它只是将当前代码模型与上次应用的迁移模型进行比较(resx中包含整个模型)文件)

As I understand what Add-Migration is doing, it's just compares the current model of code with the model of last applied migration (which has the entire model in its resx file)

对于StartupProjectName参数的描述是:

For the description of StartupProjectName paramter it says:


-StartUpProjectName

指定用于命名连接字符串的配置文件。
如果省略,则使用指定项目的配置文件。

Specifies the configuration file to use for named connection strings. If omitted, the specified project’s configuration file is used.

如果每个迁移都具有整个模型的快照,则存在

If each migration has a snapshot of whole model, then there would no need to have a database, since the current model and that snapshot are totally comparable.

所以为什么要在 Add-Migration 中提供此参数,所以不需要数据库>命令来指定连接字符串?

So why is this parameter provided in Add-Migration command to specify a connection string?

推荐答案

使用该参数,您可以指定包含连接字符串的项目(在应用程序中。配置例如)。

With that parameter you can specify the project which contains your connection string (in app.config e.g.).

您可以在单独的项目中进行迁移(不包含连接字符串)。

You can have your migrations in a seperate project (which doesn't contain the connection string).

这篇关于EF中的Add-Migration中StartupProjectName参数的用途是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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