public void Can_update() { ResetDatabase(); var logBuilder = new StringBuilder(); using (var facade = new ToolingFacade( "ClassLibrary1", "ContextLibrary1", "ClassLibrary1.Configuration", _projectDir, Path.Combine(_projectDir, "App.config"), null, null)) { facade.LogInfoDelegate = m => logBuilder.AppendLine("INFO: " + m); facade.LogVerboseDelegate = s => logBuilder.AppendLine("SQL: " + s); facade.Update(null, false); } var log = logBuilder.ToString(); Assert.True(log.Contains("INFO: Applying automatic migration")); Assert.True(log.Contains("SQL: CREATE TABLE [dbo].[Entities]")); Assert.True(DatabaseExists()); Assert.True(TableExists("Entities")); }
public virtual void RunMigration(MigrationInfo migrationInfo) { var infos = new StringBuilder(); var warnings = new StringBuilder(); var verbose = new StringBuilder(); //connection:connectionString, NameSpaceQualifiedConnectionType:for example :"System.Data.SqlClient" var connectionStringInfo = new DbConnectionInfo(migrationInfo.Connection, migrationInfo.NameSpaceQualifiedConnectionType); var toolingFacade = new ToolingFacade( migrationInfo.ContextAssemblyName, //"MyDll", // MigrationAssemblyName. In this case dll should be located in "C:\\Temp\\MigrationTest" dir migrationInfo.ContextAssemblyName, //"MyDll", // ContextAssemblyName. Same as above migrationInfo.ConfigurationTypeName, //KS.ObjectiveDataAccess.ContentManagementDbContextMigrations.Configuration migrationInfo.ContextAssemblyPath, //"C:\\Temp\\MigrationTest", // Where the dlls are located migrationInfo.WebConfigPath, //"C:\\Temp\\MigrationTest\\App.config", // Insert the right directory and change with Web.config if required migrationInfo.AppDataPath, //"C:\\Temp\\App_Data", connectionStringInfo) { LogInfoDelegate = s => { infos.AppendLine($"Infos : {s} . <br>"); }, LogWarningDelegate = s => { warnings.AppendLine($"Warning : {s} . <br>"); }, LogVerboseDelegate = s => { verbose.AppendLine($"Verbose : {s} . <br>"); } }; toolingFacade.Update(migrationInfo.TargetName, migrationInfo.Force); }
private static DelegatedMigrator CreateMigrator(string startUpConfigurationFile, string startUpDataDirectory, string connectionStringName, MigratorConfig config, DbConnection connection) { ToolingFacade facade = CreateToolingFacade(config, startUpConfigurationFile, startUpDataDirectory, connectionStringName); var migrator = new DelegatedMigrator(facade.GetPendingMigrations, facade.GetDatabaseMigrations, migration => facade.Update(migration, true), (s, t) => facade.ScriptUpdate(s, t, true), connection, facade.Dispose) { IsAutoMigrationsEnabled = config.AutomaticMigrationsEnabled }; return(migrator); }
public EntityFrameworkRepositoryBaseTests() { CodeFirstContext context = new CodeFirstContext(); if (!context.Database.Exists()) { context.Database.Initialize(true); context.SaveChanges(); } ToolingFacade facade = new ToolingFacade(typeof(TimeSheet).Assembly.FullName, typeof(TimeSheet).Assembly.FullName, typeof(Dot.UtilityTests.Migrations.Configuration).FullName, AppDomain.CurrentDomain.BaseDirectory, AppDomain.CurrentDomain.BaseDirectory + "\\Dot.UtilityTests.dll.config", null, new DbConnectionInfo("CodeFirst")); facade.Update(null, false); }
public void UpdateDatabase(String targetMigration) { _fasade.Update(targetMigration, false); }