MVC4 Scaffolding Add Controller gives error “Unable to retrieve metadata…”

By trial and error I found the line of code (it’s the DbContext ctor) that is causing the error:

public class MyThingDb : DbContext
{
    // If I comment this constructor out the scaffolding works
    public MyThingDb()
        : base("DefaultConnection")
    {
    }

    public DbSet<MyThing> Things{ get; set; }
}

WTF?

Leave a Comment