Announcing the release of Dynamic Data provider and EntityDataSource control for Entity Framework 6

Announcing the release of Dynamic Data provider and EntityDataSource control for Entity Framework 6

Rate This
  • Comments 20

Today, we are pleased to announce RTM of ASP.NET Dynamic Data and EntityDataSource control for EntityFramework 6

What’s in this release

- Dynamic Data provider for Entity Framework 6

- EntityDataSource control for Entity Framework 6

How to install

You can download this release for ASP.NET DynamicData.EFProvider (http://www.nuget.org/packages/Microsoft.AspNet.DynamicData.EFProvider/) and EntityDataSource (http://www.nuget.org/packages/Microsoft.AspNet.EntityDataSource/) from the NuGet gallery.

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

Getting started

Microsoft.AspNet.DynamicData.EFProvider

This package has a DynamicData EFProvider for EntityFramework 6. This provider can work with a Model (either Code First or Model First) which was created using Entity Framework 6. This package also installs the Page Templates, Entity Templates and Field Templates which are required for DynamicData. The templates have been updated to use Microsoft.AspNet.EntityDataSource control which we are also previewing today as well.

For more information on ASP.NET DynamicData please see http://msdn.microsoft.com/en-us/library/cc488545.aspx

Following are the steps for using this package in a ASP.NET DynamicData application:

  • Create a new ASP.NET Dynamic Data Entities Web Application
  • Add the Microsoft.AspNet.DynamicData.EFProvider NuGet package
  • This will do the following
    • Add a reference to the DynamicData EFProvider binary
    • Install the templates. If you are starting with a new project, then you can override the templates. If you have an existing application, then you should be careful when overriding the changes. These templates will replace the EntityDataSource control which shipped in .NET Framework with Microsoft.AspNet.EntityDataSource and the Page Templates, Field Templates, Entity Templates.
  • Create your model using Entity Framework Code First or EF Designer.
  • Add the following code in RegisterRoutes in Global.asax.cs to register your DbContext:
Code Snippet
  1. DefaultModel.RegisterContext(
  2. new Microsoft.AspNet.DynamicData.ModelProviders.EFDataModelProvider(() => new YourDbContext()),
  3. newContextConfiguration { ScaffoldAllTables = true });  
 
  • Run the project
  • You would see all the tables listed on the Default page.

Microsoft.AspNet.EntityDataSource Control

This is an update to the EntityDataSource control which shipped in the .NET Framework. The EntityDataSource control has been updated to work with Entity Framework 6.

To use this control, please do the following

  • Create an ASP.NET application
  • Install the package Microsoft.AspNet.EntityDataSource
    • This package will
      • Install the runtime binary for Microsoft.AspNet.EntityDataSource
      • Install the EntityFramework version 6 NuGet package
      • Add the following tag prefix in web.config
Code Snippet
  1. <pages>
  2.   <controls>
  3.     <addtagPrefix="ef"assembly="Microsoft.AspNet.EntityDataSource"namespace="Microsoft.AspNet.EntityDataSource" />
  4.   </controls>
  5. </pages>
  • Create a new Web Form page
  • Use the control as follows and bind it to any Databound control such as GridView, FormView etc.
Code Snippet
  1. <asp:GridViewID="GridView1"runat="server"DataSourceID="GridDataSource"></asp:GridView>
  2. <ef:EntityDataSourceID="GridDataSource"runat="server"EnableDelete="true"/>

Give feedback

If you find any issues with this preview, please file issues at the EntityFramework CodePlex sitehttps://entityframework.codeplex.com

Thank you for trying out this release.

Leave a Comment
  • Please add 3 and 2 and type the answer here:
  • Post
  • So, I'm trying to register context like this:

    namespace RailTrack.DataViewer

    {

       public class Global : System.Web.HttpApplication

       {

           public static void RegisterRoutes(RouteCollection routes)

           {

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

    }

    }

    }

    But I get ''Erro:Cannot implicitly convert type 'RailTrack.Data.RailTrackEntities' to 'System.Data.Entity.DbContext'"

    Could please anybody help me?

    P.S. RailTrackEntities are from EF 6.0.0

  • So silly not allowing you to save your page (this page) without having the source code to be hideen .... !!! Why ????

  • Does the new <ef:EntityDataSource> still support EntitySQL?

    for example:

    <asp:EntityDataSource ID="edsOperator" runat="server" ConnectionString="name=myEntities"

           DefaultContainerName="myEntities" EntitySetName="Code" Include="CodeType"

           OrderBy="it.Name" EntityTypeFilter="Code" Where="it.IsActive=TRUE AND it.CodeType.Name='Operator'">

    </asp:EntityDataSource>

  • I have encounter a problem. Please take a look at this page

    stackoverflow.com/.../entitydatasource-and-entity-framework-6

  • Hi, this process generates the Model to the root of the project and not inside a folder.

    If i do create the App_Code folder and the model files are created in here then the  YourDbContext gives an error. and to fix it ask to create class of YourDbContext name. in ef5 the deafault was that the model be in the App_Code.

    please help.. thank you.

Page 2 of 2 (20 items) 12