Common ASP.NET Dynamic Data Error

A few folks trying out Dynamic Data have run across this error and emailed me about it:

“There are no accessible tables. Make sure that at least one data model is registered in Global.asax and scaffolding is enabled or implement custom pages”

It means that you forgot to register your data model (LINQ to SQL or Entity Framework) in the Global.asax file, so the dynamic data engine doesn’t know what data to merge with what field and page templates. Here’s the code you need to add to Global.asax to get it working:

void Application_Start(object sender, EventArgs e)
{
    MetaModel model = new MetaModel();
    
    model.RegisterContext(typeof(YourDataContextType), 
        new ContextConfiguration() { ScaffoldAllTables = true });}
}

Where YourDataContextType is the name of your data model’s DataContext object. Error no more, your data model is now registered and the engine is aware of it.

#1 mozzy on 10.07.2008 at 6:05 PM

Hey there,

I ran across the same error however I did register my datacontext in the global.asax

What could the reasons be?

#2 rachel on 10.07.2008 at 6:11 PM

Did you also make sure that the ScaffoldAllTables is set to true?