BT

DynamicData and EntityDataSource Updated with Entity Framework 6 Support

by Anand Narayanaswamy on Feb 01, 2014 |

Microsoft has added Entity Framework 6 support for DynamicData and EntityDataSource controls in addition to updated templates which make use of Microsoft.AspNet.EntityDataSource. The DynamicData package works either with code first or model first created using Entity Framework 6, which also installs the required page, entity and field templates.

In order to use DynamicData control, you should create a new ASP.NET Dynamic Data entities web application and add the Microsoft.AspNet.DynamicData.EFProvider NuGet package which will ultimately add a reference to the DynamicData EFProvider binary and installs the required templates.

You should then create model using EF code first or designer and add the below code in Global.asax.cs file, which will register your Entity Framework model.

DefaultModel.RegisterContext(
new Microsoft.AspNet.DynamicData.ModelProviders.EFDataModelProvider(() => newNorthwindEntities1()),
newContextConfiguration { ScaffoldAllTables = true });

On the other hand, Microsoft.AspNet.EntityDataSource package will install the runtime binary and EntityFramework version 6 NuGet package. You should also add the following tag prefix in web.config file as mentioned below

<pages>
<controls>
<addtagPrefix="ef"assembly="Microsoft.AspNet.EntityDataSource"
namespace="Microsoft.AspNet.EntityDataSource" />
</controls>
</pages>

Finally, you should create a new web form page and bind the EntityDataSource control to either GridView or FormView using the code below

<ef:EntityDataSourceID="GridDataSource"runat="server"EnableDelete="true"/>

The installed templates replace the default EntityDataSource control with Microsoft.AspNet.EntityDataSource package. It also includes few bug fixes which resolve few issues associated with Many-Many field template. However, the templates included with Microsoft.AspNet.DynamicData.EFProvider are oriented for C# and Web Application projects and will not work with WebSites projects.

Hello stranger!

You need to Register an InfoQ account or to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread
Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Discuss

Educational Content

General Feedback
Bugs
Advertising
Editorial
InfoQ.com and all content copyright © 2006-2013 C4Media Inc. InfoQ.com hosted at Contegix, the best ISP we've ever worked with.
Privacy policy
BT