dbmigrator

Manually Provide DbContext to DbMigrator

十年热恋 提交于 2020-01-31 15:07:12
问题 Platform .NET 4.5 and Entity Framework 6. Question I have the following code to execute a Migration: //The following function just returns an object of the Configuration() class //generated by code migrations var migratorConfig = currentMigrationProvider.CreateDbMigrationConfiguration(); var dbMigrator = new System.Data.Entity.Migrations.DbMigrator(migratorConfig); dbMigrator.Update(); The problem is that Update() function tries to create an instance of my DbContext class and for a few good

Manually Provide DbContext to DbMigrator

会有一股神秘感。 提交于 2020-01-31 15:06:53
问题 Platform .NET 4.5 and Entity Framework 6. Question I have the following code to execute a Migration: //The following function just returns an object of the Configuration() class //generated by code migrations var migratorConfig = currentMigrationProvider.CreateDbMigrationConfiguration(); var dbMigrator = new System.Data.Entity.Migrations.DbMigrator(migratorConfig); dbMigrator.Update(); The problem is that Update() function tries to create an instance of my DbContext class and for a few good

Manually Provide DbContext to DbMigrator

邮差的信 提交于 2020-01-31 15:04:27
问题 Platform .NET 4.5 and Entity Framework 6. Question I have the following code to execute a Migration: //The following function just returns an object of the Configuration() class //generated by code migrations var migratorConfig = currentMigrationProvider.CreateDbMigrationConfiguration(); var dbMigrator = new System.Data.Entity.Migrations.DbMigrator(migratorConfig); dbMigrator.Update(); The problem is that Update() function tries to create an instance of my DbContext class and for a few good

Possible to add migration using EF DbMigrator

[亡魂溺海] 提交于 2019-12-13 06:07:21
问题 Is it possible to add a migration file using DbMigrator in code instead of through the powershell commands? 回答1: DbMigrator is class for running migrations. Classes for creating migration are in System.Data.Entity.Migrations.Design. ToolingFacade is called by powershell commands. Other classes represents low level API for creating migration code. 来源: https://stackoverflow.com/questions/12353840/possible-to-add-migration-using-ef-dbmigrator

DbMigrator.GetPendingMigrations() always empty

蹲街弑〆低调 提交于 2019-12-12 10:55:21
问题 I'm using the DbMigrator class to get a list of pending migrations. For some reason it returns no items even though there are pending migrations. Am i missing a step? var configuration = new Migrations.Configuration(); configuration.TargetDatabase = new DbConnectionInfo("MyDatabase"); var migrator = new DbMigrator(configuration); var migs = migrator.GetPendingMigrations().ToList(); Console.WriteLine(migrator.GetPendingMigrations().ToString()); I thought it might be the connection string but

Manually Provide DbContext to DbMigrator

我是研究僧i 提交于 2019-12-03 15:42:05
Platform .NET 4.5 and Entity Framework 6. Question I have the following code to execute a Migration: //The following function just returns an object of the Configuration() class //generated by code migrations var migratorConfig = currentMigrationProvider.CreateDbMigrationConfiguration(); var dbMigrator = new System.Data.Entity.Migrations.DbMigrator(migratorConfig); dbMigrator.Update(); The problem is that Update() function tries to create an instance of my DbContext class and for a few good reasons I need to manually create the context and feed it to dbMigrator. Is that possible? How? Yes it