public void ExampleOfUsingApply() { using (var context = new MyDbContext()) { var enumToLookup = new EnumToLookup(); enumToLookup.NameFieldLength = 42; // optional, example of how to override default values // This would normally be run inside either a db initializer Seed() // or the migration Seed() method which both provide access to a context. enumToLookup.Apply(context); } }
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); } }