Domanda

Code first migrations have been working very well for me. I have a services project and a wpf project. The model is in the services project which is referenced by the wpf project. Update-database is done on the services project, but uses connection string from the wpf project. I now add a web project which also references the service project. So now that there is a connection string in the app.config and there is one in the web.config, which one will it use?

È stato utile?

Soluzione

In my scenario, the app.config in the services project is ignored. Code first migrations will use either the app.config from the WPF project or the web.config on the web project, depending which is selected as the startup project.

Altri suggerimenti

When doing update-database you should specify the project that contains the migrations. Make sure that you have an app.config file in that project that contains the correct connection string.
you can do a Update-Database -ConnectionStringName "MyConnectionString" and it should work like a charm.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top