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

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

Rate This
  • Comments 21

Today, we are pleased to announce an update to ASP.NET DynamicData and EntityDataSource control, so that they work with Entity Framework 6.

What’s in this preview

- DynamicData provider for Entity Framework 6

- EntityDataSource control for Entity Framework 6

How to install this preview

You can download this preview for ASP.NET DynamicData.EFProvider (http://www.nuget.org/packages/Microsoft.AspNet.DynamicData.EFProvider/) and EntityDataSource (http://www.nuget.org/packages/Microsoft.AspNet.EntityDataSource/) as preview NuGet packages from the NuGet gallery. You can install these pre-release packages through NuGet using the NuGet Package Manager Console, like this:

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

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. The templates replace the EntityDataSource control which shipped in .NET with Microsoft.AspNet.EntityDataSource and also have a few bug fixes in the Many-Many field template so they work with EntityFramework 6.
    • Create your model using Entity Framework Code First or EF Designer.
    • Add the following code in RegisterRoutes in Global.asax.cs to register your EF Model:
Code Snippet
  1. DefaultModel.RegisterContext(
  2.     new Microsoft.AspNet.DynamicData.ModelProviders.EFDataModelProvider(() => newNorthwindEntities1()),
  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. <ef:EntityDataSourceID="GridDataSource"runat="server"EnableDelete="true"/>

Known Issues

  • The templates in Microsoft.AspNet.DynamicData.EFProvider are for C# only.
  • The templates in Microsoft.AspNet.DynamicData.EFProvider are for Web Application projects only and will not work for WebSites projects.

Give feedback

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

Thank you for trying out the preview and helping us make it better.

  • C# only. Sure is frustrating for those of us who have spent 10yrs on vb.net.

  • Thanks a lot !!! I was needing this feature !!! :)

  • Good introduction on the update of .ASPNet.

    Thanks a lot for the share.

  • Hi,

    Can we please have a better description of what this is and what the advantages are of using it. It appears to be a web forms control. If so, a screen shot would not go amiss.

    Thank You

  • Great Blog & Thanks for sharing this information..........

  • Awesome description I really really really LIKE IT!!! XD

    I didn't understand a thing but the description is so great that I can understand it a-little!!! XD

    How to install this preview:

    """You can download this preview for ASP.NET DynamicData.EFProvider (www.nuget.org/.../Microsoft.AspNet.DynamicData.EFProvider) and EntityDataSource (www.nuget.org/.../Microsoft.AspNet.EntityDataSource) as preview NuGet packages from the NuGet gallery. You can install these pre-release packages through NuGet using the NuGet Package Manager Console, like this:

    Install-Package Microsoft.AspNet.DynamicData.EFProvider -Version 6.0.0-alpha1 –Pre

    Install-Package Microsoft.AspNet.EntityDataSource -Version 6.0.0-alpha1 –Pre"""

    Why can't I click the link...!? -.-

  • @Newbie Com Tech Boy, thanks, link added to the URLs.

  • @duped guy: ... and in all those 10yrs you didn't realize that VB.NET was created to be a transition language? Worse than that, do you see that much difference between both languages that you couldn't port the code between them?

  • I'm having a problem. Previously, I was using the following code to set the ObjectContext using the OnContextCreating event. Also, I was setting the CommandTimeout. Now it says it can't convert System.Data.Entity.Core.Objects.ObjectContext to System.Data.Objects.ObjectContext. The CommandTimeout property appears to no longer be there either.

           protected void WorkUnitsEntityDataSource_ContextCreating(object sender, EntityDataSourceContextCreatingEventArgs e)

           {

               e.Context = ((IObjectContextAdapter)libraryContext).ObjectContext;

               e.Context.CommandTimeout = 300;

           }

    The reason I was doing this is because EntityDataSource expected an ObjectContext, not a DbContext. I'm wondering if setting the context this way is still necessary? But, even if it isn't, I need to set the CommandTimeout for the context because the queries I'm executing are against large data sets.

  • I got it working. I didn't realize that you had to change the control to use ef: instead of asp:. You also need to specify the namespace for the EventArgs class. So, I guess the asp: one will be deprecated and removed at some point? Or will the ef: be renamed to asp: when the release comes out?

  • Unfortunately, the reason why I've been using the EntityDataSource control no longer seems to be working. When used with Telerik's RadGrid control, filtering would happen in the SQL server rather than the web server. It's now doing the filtering in the web server. I'm not sure if the issue is with Telerik's control or with the new EntityData Source control. I noticed that paging filtering is still working. This is important to me because I'm using the grid with some tables that have a lot of rows in them. Doing the filtering in the web server is inefficient and will cause an OutOfMemoryError.

  • Thank you.  Seems to work well for a EF6 runtime datasource.  Will future non alpha EntityDataSource versions support design time field retrieval?

  • @Jon can you please email me your issue at pranav.rastogi@microsoft.com so we can investigate.

  • @PKBubba the future version of the datasource will not support design time retrieval of fields.

  • We appreciate your support for Web Forms

Page 1 of 2 (21 items) 12