I am using FluentMigrator.dll for DB settings and I want it can create or update its database when program ran any server.
So I visited this page for this problem
Is it possible to use fluent migrator in application_start?
And get these codes to my project;
public static void MigrateToLatest(string connectionString)
{
var announcer = new TextWriterAnnouncer(s => System.Diagnostics.Debug.WriteLine(s));
var assembly = Assembly.GetExecutingAssembly();
CreateDB(connectionString);
var migrationContext = new RunnerContext(announcer)
{
Namespace = "Mueasyco.MVCWebUI.Migrations.DefaultDB"
};
var options = new MigrationOptions { PreviewOnly = false, Timeout = 60 };
var factory =
new FluentMigrator.Runner.Processors.SqlServer.SqlServer2012ProcessorFactory();
using (var processor = factory.Create(connectionString, announcer, options))
{
var runner = new MigrationRunner(assembly, migrationContext, processor);
runner.MigrateUp();
}
}
You will see at there CreateDB() method, it provides a DB for my project.
So, MigrateUp() does not give any errors but it does not work
Thanks for your answers