BT

New Early adopter or innovator? InfoQ has been working on some new features for you. Learn more

DynamicData and EntityDataSource Updated with Entity Framework 6 Support

| by Anand Narayanaswamy on Feb 01, 2014. Estimated reading time: 1 minute |

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.

Rate this Article

Adoption Stage
Style

Hello stranger!

You need to Register an InfoQ account or or login 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

Login to InfoQ to interact with what matters most to you.


Recover your password...

Follow

Follow your favorite topics and editors

Quick overview of most important highlights in the industry and on the site.

Like

More signal, less noise

Build your own feed by choosing topics you want to read about and editors you want to hear from.

Notifications

Stay up-to-date

Set up your notifications and don't miss out on content that matters to you

BT