Introducing EntityDataSource Control Final Release in ASP.Net

Introdcution

Today, I am introducing the release of Dynamic Data Provider and EntityDataSource for the Entity Framework 6. I've also described in the Preview Release that the preview of these features were released earlier and here comes the final release.

You can determine the following features in this release:

  • EntityDataSource for Entity Framework 6
  • Dynamic Data Provider for Entity Framework 6

Download

You can easily download this release by the following NuGet Package:

  • Install-Package Microsoft.AspNet.DynamicData.EFProvider -Version 6.0.0
  • Install-Package Microsoft.AspNet.EntityDataSource -Version 6.0.0

Getting Started with Dynamic Data Provider

This is the new release of Dynamic Data EFProvider for the Entity Framework 6. You can apply any approach here like Code First, Model First and Database First to associate with the Entity Framework.

When creating the Dynamic Data Entities Web Application and after installing the Microsoft.AspNet.DynamicData.EFProvider NuGet Package, we can add the following code in RegisterRoutes in the Global.asax.cs to register the DbContext that is defined as in the following:

  1. public static void RegisterRoutes(RouteCollection routes)  
  2. {  
  3.       DefaultModel.RegisterContext(new Microsoft.AspNet.DynamicData.ModelProviders.EFDataModelProvider(  
  4.           () => new Cricketer_SiteEntities()),  
  5.           new ContextConfiguration { ScaffoldAllTables = true });  
  6. } 

When the application creation is successful, you can run the application and see that the list of tables are displayed on the Default page.

Getting Started with EntityDataSource

This is an update to the EntityDataSource control that shipped in the .NET Framework. Now the EntityDataSource control can work with the Entity Framework 6 since this is updated to work with it.

Now in this section, we'll work with this update in the ASP.NET web application. Use the following procedure.

Step 1: Create the ASP.NET web application in the Empty Project Template.

Empty Project Template in VS 2013

Step 2: Install the Microsoft.AspNet.EntityDataSource package from the Package Manager Console using the following command:

Install-Package Microsoft.AspNet.EntityDataSource -Version 6.0.0

The command installs this package in the application.

EntityDataSource NuGet Package

You can see that the preceding command installs the package. This package will also install the runtime binary for the Microsoft.AspNet.EntityDataSource and latest Entity Framework 6.

Step 3: In your Web.Config file the following markup is added automatically:

  1. <pages>  
  2.       <controls>  
  3.         <add tagPrefix="ef" assembly="Microsoft.AspNet.EntityDataSource"   
  4.             namespace="Microsoft.AspNet.EntityDataSource" />  
  5.       </controls>  
  6. </pages> 

Step 4: Add a New Web Form in the application by right-clicking on the application and add a new item.

Step 5: Now we can use the the EntityDatasSource control to bind with any DataBoundControl like GridView, FormView and so on.

As an example: I am binding it with the GridView Control. Have a look at the following syntax:

  1. <body>  
  2.     <form id="form1" runat="server">  
  3.     <div>  
  4.     <asp:GridView ID="DataGridView" runat="server" DataSourceID="EntityDataSource">  
  5.      </asp:GridView>  
  6.         <ef:EntityDataSource ID="EntityDataSource" runat="server" EnableDelete="true" />  
  7.     </div>  
  8.     </form>  
  9. </body> 

That's it.

Summary

This article described the release of Dynamic Data Provider and EntityDataSource with its latest version 6.0.0. Thanks for reading and Stay Updated.