I'm coming from asp.net Web Forms switching to MVC and entity framework code first approach. I have a question. How can I set up my environment to deploy to production?
I'm using Visual Studio 2012 and deploys a web deploy package. Locally I have SQL Express and in production, I have SQL Server 2008.
What I want is to develop an test locally on my pc and from time to time deploy my solution to production with a web deploy package. I don't want to run migrations in the production system, instead, I want to generate scripts from visual studio which I then can append to production SQL.
I tried to:
Is this the correct approach? What about my migrations that will run locally, will they not in production to when I deploy because of my migrations code?
In global.asax
Migrator.RunMigrations();
where RunMigrations is a static method in a custom Migrator class like this
public class Migrator
{
public static void RunMigrations()
{
var migrator = new Configuration();
var dbMigrator = new System.Data.Entity.Migrations.DbMigrator(migrator);
if (dbMigrator.GetPendingMigrations().Any())
{
dbMigrator.Update();
}
}
}
Yes, we use it in production.
Deploy the app to AzureIn Visual Studio, right-click the project in Solution Explorer and select Publish from the context menu. On the Pick a publish target page, choose App Service and then Select Existing, and then choose Publish.
You can with Web Setup Project (for the installation an MSI Custom Action is needed):
The actual work of updating the database is can be done by the migrate.exe tool. To make the MSI package run it properly turned out to be a bit of a challenge. I first included migrate.exe in the installation package to have it deployed to the bin directory together with the assemblies of the system. There is support for running a .exe file as a custom action in the web setup projects. Unfortunately, I couldn’t get migrate.exe to work unless the working directory was set to the bin directory. The working directory for custom actions is c:\windows\system32 by default. To handle that, a small vb-script was used.
http://coding.abel.nu/2012/04/update-database-msi-custom-action/
UPDATE:
I found this, this and this, maybe it will help.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With