Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
All-Star
27308 Points
5458 Posts
MVP
Jul 19, 2010 10:12 AM|LINK
Hi , it seems to work for me have a look at my Global.asax.cs:
public class Global : System.Web.HttpApplication { private static MetaModel s_defaultModel = new MetaModel(); public static MetaModel DefaultModel { get { return s_defaultModel; } } public static void RegisterRoutes(RouteCollection routes) { EntityConnectionStringBuilder entityBuilder = new EntityConnectionStringBuilder(); entityBuilder.Provider = "System.Data.SqlClient"; entityBuilder.ProviderConnectionString = "server=aragorn;database=Northwind;Integrated Security=SSPI;MultipleActiveResultSets=True"; entityBuilder.Metadata = @"res://*"; var objContext = new NorthwindContext.NorthwindEntities(entityBuilder.ToString()); DefaultModel.RegisterContext(() => new NorthwindContext.NorthwindEntities(entityBuilder.ToString()), new ContextConfiguration() { ScaffoldAllTables = true }); routes.Add(new DynamicDataRoute("{table}/{action}.aspx") { Constraints = new RouteValueDictionary(new { action = "List|Details|Edit|Insert" }), Model = DefaultModel }); } void Application_Start(object sender, EventArgs e) { RegisterRoutes(RouteTable.Routes); } }
Note that I tried it in an DD4 Web Application Project.
Dynamic Data
sjnaughton
All-Star
27308 Points
5458 Posts
MVP
Re: Entity Framework: Entity Model in a separated dll
Jul 19, 2010 10:12 AM|LINK
Hi , it seems to work for me have a look at my Global.asax.cs:
public class Global : System.Web.HttpApplication { private static MetaModel s_defaultModel = new MetaModel(); public static MetaModel DefaultModel { get { return s_defaultModel; } } public static void RegisterRoutes(RouteCollection routes) { EntityConnectionStringBuilder entityBuilder = new EntityConnectionStringBuilder(); entityBuilder.Provider = "System.Data.SqlClient"; entityBuilder.ProviderConnectionString = "server=aragorn;database=Northwind;Integrated Security=SSPI;MultipleActiveResultSets=True"; entityBuilder.Metadata = @"res://*"; var objContext = new NorthwindContext.NorthwindEntities(entityBuilder.ToString()); DefaultModel.RegisterContext(() => new NorthwindContext.NorthwindEntities(entityBuilder.ToString()), new ContextConfiguration() { ScaffoldAllTables = true }); routes.Add(new DynamicDataRoute("{table}/{action}.aspx") { Constraints = new RouteValueDictionary(new { action = "List|Details|Edit|Insert" }), Model = DefaultModel }); } void Application_Start(object sender, EventArgs e) { RegisterRoutes(RouteTable.Routes); } }Note that I tried it in an DD4 Web Application Project.
Dynamic Data
Always seeking an elegant solution.