protected override void Seed(LogDbContext context) { var enumToAdd = new EnumToLookup(); var migrationSql = enumToAdd.GenerateMigrationSql(context); enumToAdd.Apply(context); base.Seed(context); }
private static void ConvertirEnTablaLosEnumDelCodigoUtilizadosEnElDbContext(ApplicationDbContext context) { var enumToLookup = new EnumToLookup(); var sql = enumToLookup.GenerateMigrationSql(context); sql = AgregarDboEnLaCreacionDeTablasPorSiNoEsElEsquemaDefault(sql); context.Database.ExecuteSqlCommand(sql); context.SaveChanges(); }
public void ExampleOfGeneratingSql() { using (var context = new MyDbContext()) { var enumToLookup = new EnumToLookup(); // if you need to get at the raw sql to run a migration separately then use: var migrationSql = enumToLookup.GenerateMigrationSql(context); // you'd probably want to write this to a file and then add it to source control, but for // the purpose of demonstration we'll write it to the console instead: Console.Out.WriteLine(migrationSql); // at some point you'd then run the sql (probably not like this, but this serves as a test that it's working) context.Database.ExecuteSqlCommand(migrationSql); } }
protected override void Seed(STM.Common.DataAccess.StmDbContext context) { //throw new Exception(); var mt1 = new MessageType { Name = "RTZ", SchemaXSD = "rtz.xsd" }; var mt2 = new MessageType { Name = "TXT", SchemaXSD = "textMessageSchema.xsd" }; var mt3 = new MessageType { Name = "S124", SchemaXSD = "s124.xsd" }; var mt4 = new MessageType { Name = "PCM", SchemaXSD = "port-call-message_v0.16.xsd" }; if (!context.MessageType.Any()) { context.MessageType.Add(mt1); context.MessageType.Add(mt2); context.MessageType.Add(mt3); context.MessageType.Add(mt4); context.SaveChanges(); } var enumToAdd = new EnumToLookup(); var migrationSql = enumToAdd.GenerateMigrationSql(context); enumToAdd.Apply(context); base.Seed(context); }