Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Enable-Migrations, I don't get it - EF6

Enable-Migrations, I don't get it - EF6

Scheduled Pinned Locked Moved Database
databasequestionworkspace
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jkirkerx
    wrote on last edited by
    #1

    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
    
    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups