Entity Framework Migrations with Multiple Web Configuration Transforms

I created an ASP.NET MVC 4 project in Visual Studio 2010 using Entity Framework 5 with migrations enabled. I have several web configuration files for different environments (Debug, Staging, Release), which will determine different database connections depending on the environment. How to handle migrations using a command Update-Databasefrom the package manager console with multiple configuration files? Each time I run this command, the default Web.config connection string is used by default. Thanks for any help in advance.

+5
source share
3 answers

, , , - ( / ):

Update-Database -Verbose -ConnectionString "Data Source=ServerName;Initial Catalog=db;User Id=user;Password=pass;" -ConnectionProviderName "System.Data.SqlClient"

, - . .

+6

, -, , Entity Framework.

0

http://msdn.microsoft.com/en-us/data/jj618307.aspx

EF Code First Migrations , "update" .

I'm not quite sure how you tuned in, but we did something similar when we deploy the code through our CI server (Jenkins). Then I added a post-deployment step to run the update database through the command line.

What's good about this is you can also specify connection strings.

Again, it all depends on how it fits into your process; you can even use Nant to do this for you.

Hope this helps.

0
source

All Articles