Enable-Migrations, I don't get it - EF6
-
So my program is almost complete, and I'm trying to enable migrations in my project. I did the package command -Enable-Migration -EnableAutmaticMigration Here's the part I don't get. I wrote a Intializer that makes the database and seeds it with data, which works fines. Here I call the class I made show below in the first class
public indigoDBContext() : base("DefaultConnection")
{
// Enable the Intializer
Database.SetInitializer(new indigoIntializer());
}Then I ran PM -EnableMigrations -EnableAutomaticMigrations And my Intializer file changed, it added a class called Configuration, what I am suppose to do with this class?, OK, so I changed the commented code to my seed code.
class indigoIntializer : CreateDatabaseIfNotExists
{
protected override void Seed(indigoDBContext context)
{
base.Seed(context);// Seed the Website Adminsitrator Table siteAdministrators.seed(context); // Seed the Website Countries and States countries.seed(context); states\_Provinces.seed(context); salesTax.seed(context); avatars.seed(context); themes.seed(context); paymentGateways.seed(context); paymentBrands.seed(context); }
}
class Configuration : DbMigrationsConfiguration
{
public Configuration()
{
AutomaticMigrationsEnabled = true;
ContextKey = "Indigo.DataAccessLayer.indigoDBContext";
}protected override void Seed(Indigo.DataAccessLayer.indigoDBContext context) { base.Seed(context); // Seed the Website Adminsitrator Table siteAdministrators.seed(context); // Seed the Website Countries and States countries.seed(context); states\_Provinces.seed(context); salesTax.seed(context); avatars.seed(context); themes.seed(context); paymentGateways.seed(context); paymentBrands.seed(context); }
}
Then it added a file called Configurations.cs in a Migration folder, so I added my seed code to that as well.
internal sealed class Configuration : DbMigrationsConfiguration
{
public Configuration()
{
AutomaticMigrationsEnabled = true;
}protected override void Seed(Indigo.DataAccessLayer.indigoDBContext context) { base.Seed(context); // Seed the Website Adminsitrator Table siteAdmi