Entity DataSource not working with Entity Framework 6 Upgrade

前端 未结 3 1353
温柔的废话
温柔的废话 2020-12-06 12:03

I recently upgraded our Webforms application from EF 4.4 to EF6 and I got so many compile time build errors with the Entity Datasource controls. Generally I am getting these

相关标签:
3条回答
  • 2020-12-06 12:28

    As per the suggestions given by the IDE, we can go to the NuGet Package Console and run the following command to install the new Entity Framework data source:

    Install-Package Microsoft.AspNet.EntityDataSource
    

    Also, add the following package (as referred in this article):

    Install-Package Microsoft.AspNet.DynamicData.EFProvider
    
    0 讨论(0)
  • 2020-12-06 12:31

    I just went through this exercise when upgrading to EF 6 from EF 5 and I had the same errors.

    Here is what I had to do.

    Install-Package Microsoft.AspNet.EntityDataSource
    

    It would register a new EntityDataSource Control in the web.config under pages:

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

    Next step is to replace existing <asp:EntityDataSource /> controls to <ef:EntityDataSource /> in your aspx pages.

    Final step is to go in your code behind and update references for EntityDataSourceContextCreatingEventArgs or any other type of EFContext tags.

    From

    protected void OnContextCreating(object sender, EntityDataSourceContextCreatingEventArgs e){... } 
    

    To

    protected void OnContextCreating(object sender, Microsoft.AspNet.EntityDataSource.EntityDataSourceContextCreatingEventArgs e){... } 
    

    It all worked and I didn't have to reference System.Data.Entity in the assembly.

    0 讨论(0)
  • 2020-12-06 12:38

    The Entity DataSource control for EF6 is available in preview since 2014-01-30 (details in this Microsoft announcement). It is available as a nuget package : http://www.nuget.org/packages/Microsoft.AspNet.EntityDataSource/

    If you try to download it from the nuget package manager, be sure to select the "include prerelease" item in the top combo Box.

    0 讨论(0)
提交回复
热议问题