User-1712241964 posted
Would anyone have an idea of how I should be checking to see if a model is already registered?
Here is what I initially wanted to put in my global.asax:
MetaModel model1 =
new
MetaModel();
model1.RegisterContext(typeof(gmsdb1DataContext),
new
ContextConfiguration() { ScaffoldAllTables =
false });
I can't do it in the global.asax/'Application_Start', so I am trying to do it in the next best place, and HttpModule INIT event.
Problem. My page runs fine the first time it is used, but the second time it is used it errors saying that the "Item has already been registered....", so I figure I need the httpmodule to do a check to see if the context is already registered.
Here is what I have so far, but that is not successfully registering the context:
public class AddDD : IHttpModule
{
public void Init(HttpApplication context)
{
try
{
MetaModel model1 = MetaModel.GetModel(typeof(gmsdb1DataContext));
}
catch (InvalidOperationException)
{
MetaModel model1 = new MetaModel();
model1.RegisterContext(typeof(gmsdb1DataContext), new ContextConfiguration() { ScaffoldAllTables = false });
}
}
public void Dispose(){}
}
Any thoughts, ideas, or suggestions would be appreciated.
-Gary