What's the purpose of StartupProjectName param

2019-07-22 11:00发布

问题:

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)

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.

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

回答1:

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).



回答2:

Add-Migration does not require "-StartUpProjectName" since you can choose the "default project" from the drop list above the package-manager console. You can override the "default project" value from the drop list by using the parameter "-StartUpProjectName"