Table of Contents

IT:AD:Code First:Seeding

Define the Database Initializer

Somewhere early, define this:

Database.SetInitializer(new MyInitializer());

This will be a custom implementation of IDatabaseInitializer that enherits from a well-known strategy:

//Invoke *early*, eg from a Boottrapper:
//Database.SetInitializer<GraphContext>(new GraphInitializer());
public class MyInitializer : DropCreateDatabaseIfModelChanges<TestContext>
{
  ...

  protected override void Seed(GraphContext context)
  {
  
    BuildCountryLookup(context);

    //etc
  }
}

TODO

Resources