Thursday, August 16, 2012

Using Dynamic Data with Entity Framework DbContext

Using Dynamic Data with Entity Framework DbContext: In Visual Studio 2012, if you create a ADO.NET Data Model then the generated Context class derives from a type called DbContext instead of ObjectContext. DbContext is also used when you are using EntityFramework Code First This post outlines the changes you have to do to your Dynamicdata project template if you want your context to derive from DbContext 1. Change Global.asax to get the ObjectContext DefaultModel.RegisterContext(() => { return ((IObjectContextAdapter) new YourContextType()).ObjectContext; }, new ContextConfiguration() { ScaffoldAllTables = true }); 2. Change ManyToMany.ascx.cs in the Dynamicdata\Fieldtemplates folder protected override void OnDataBinding(EventArgs e) { base .OnDataBinding(e);   object entity; ICustomTypeDescriptor...(read more)

DIGITAL JUICE

No comments:

Post a Comment

Thank's!