title: Best way to incrementally seed data in Entity Framework 4.3
body: <p>I have been using Entity Framework 4.3 on an existing database and I have a couple of scenarios that I am trying to cater for.</p>
  
  <p>Firstly, if I delete my database I would like to EF to recreate if from scratch - I have successfully used a CreateDatabaseIfNotExists database initialiser for this.</p>
  
  <p>Secondly, if I update my model and the database already exists I would like the database to be updated automatically - I have  successfully used Entity Framework 4.3 Migrations for this.</p>
  
  <p>So here's my question.  Say I add a new table to my model which requires some reference data, what it the best way to ensure that this data gets created both when the database intialiser runs and also when the migration runs.  My desire is that the data gets created when I'm creating the db from scratch and also when the database gets updated as the result of a migration running.</p>
  
  <p>In some EF migrations examples I have seen people use the SQL() function in the UP method of the migration to create seed data but if possible I would rather use the context to create the seed data (as you see in most database initialiser examples) as it seems strange to me that you would use pure sql when the whole idea of EF is abstracting that away.  I have tried to use the context in the UP method but for some reason it didn't think that a table that was created in the migration existed when I tried to add the seed data directly below the call to create the table.</p>
  
  <p>Any wisdom greatly appreciated.</p>