I have created a SeedData class, and populated it with the values that I would like to be populated into the table. When I run the application, I am not getting any errors, but the table is not populating with the Seed Data.
I am using ASP.NET MVC3 and EF 4.1
I have tried both DropCreateDatabaseAlways and DropCreateIfModelChanges with no luck
In the Global ASAX I have the following link in Application_Start
System.Data.Entity.Database.SetInitializer(new EDWv2.Models.SeedData());
My SeedData class is define as follows:
public class SeedData : DropCreateDatabaseAlways<EDWContext>
{
protected override void Seed(EDWContext context)
{
var controlsystemdesignation = new List<ControlSystemDesignation>
{
new ControlSystemDesignation { Name = "BA"},
new ControlSystemDesignation { Name = "BP"},
new ControlSystemDesignation { Name = "RA"},
new ControlSystemDesignation { Name = "GA"},
new ControlSystemDesignation { Name = "WA"},
new ControlSystemDesignation { Name = "WB"},
new ControlSystemDesignation { Name = "WC"},
new ControlSystemDesignation { Name = "EA"},
new ControlSystemDesignation { Name = "EB"},
new ControlSystemDesignation { Name = "EC"},
new ControlSystemDesignation { Name = "DA"},
new ControlSystemDesignation { Name = "DB"},
new ControlSystemDesignation { Name = "DC"},
new ControlSystemDesignation { Name = "FA"},
new ControlSystemDesignation { Name = "FB"},
new ControlSystemDesignation { Name = "SA"},
new ControlSystemDesignation { Name = "SB"},
new ControlSystemDesignation { Name = "SC"},
new ControlSystemDesignation { Name = "LA"},
new ControlSystemDesignation { Name = "LD"},
new ControlSystemDesignation { Name = "DP"},
new ControlSystemDesignation { Name = "PA"},
new ControlSystemDesignation { Name = "PB"},
new ControlSystemDesignation { Name = "PC"},
new ControlSystemDesignation { Name = "UL"},
new ControlSystemDesignation { Name = "UA"}
};
base.Seed(context);
context.SaveChanges();
}
}
Thanks,
Jason
You need to add
ControlSystemDesignationentities tocontext.