I am using E.F. with Code First approach... Now I have to fill the database with some data... but I cannot do it easily... Simething is not clear... I have googled but every solution I have found suppose I must create a custom Initilization... but I do not want to create a custom Initialization..
What I need is a method the everytime I launch some tests DROP the database, RE-CREATE it and fill it with some data.
What I have tried to do is:
public PublicAreaContext()
: base("PublicAreaContext")
{
Database.SetInitializer<PublicAreaContext>(new DropCreateDatabaseAlways<PublicAreaContext>());
}
Then I have tried to impement the Seed method inside the Configuration class. So:
internal sealed class Configuration : DbMigrationsConfiguration<PublicAreaContext>
{
protected override void Seed(PublicAreaContext context)
{
...
}
}
But when I try to debug I never go in the seed method... I go in constructor of the Configuration class, but not in the seed... why?
Thanx for your help