Entity Framework Code First: initializing a database using a console application

I am trying to run the initialization code and it does not work. Here is what I have in the main method

    static void Main(string[] args)
    {
        Database.SetInitializer<Context>(new RecipesSeedData());

    }

Should I put something else basically to get it to run the code below? When I look at the code in the debugger, it does not even reach the initialization code, which makes me feel that I am missing something important.

public class RecipesSeedData : DropCreateDatabaseAlways<Context>
{
    protected override void Seed(Context context)
    {
        var mt = new MenuType {MenuTypeId = 1};

        context.MenuTypes.Add(mt);

        base.Seed(context);
    }
}
+3
source share
1 answer
+7

All Articles