locked
Can't configure EntityDataSource under Entity framework version 6 RRS feed

  • Question

  • User291446270 posted

    Hi,

     I have been searching for the answer for this problem more than 2 weeks, I hope anyone could help.

    I have just start a new project and I did install the Entity framework v6.4.4 to my project. I also installed the Microsoft.AspNet.EntityDataSource and Microsoft.AspNet.DynamicData.EFProvider from the nudget package.  But then , I drag and drop the EntityDataSource control from toolbox to my web form. I want to configure the data source but Error Message pop up "THIS VERSION OF THE ENTITY DATA SOURCE WIZARD IS ONLY COMPATIBLE WITH ENTITY FRAMEWORK 5.IF YOU'RE NOT USING ENTITY FRAMEWORK 5 YOU CAN CONFIGURE THE CONTROL BY EDITING THE MARKUP ON THE PAGE.THE PAGE EDITOR HAS INTELLISENSE SUPPORT FOR ASP.NET CONTROLS.IF YOU'RE USING ENTITY FRAMEWORK 6 YOU SHOULD ALSO BE USING THE EF-6 COMPATIBLE VERSION OF THE ENTITY DATA SOURCE CONTRL, AVAILABLE AS THE MICROSOFT.ASPNET.ENTITYDATASOURCE PACKAGE IN NuGet."  

    So I follow the error message and installed the entity datasource control and dynamicdata provider from Nudget but still cannot configure. I read some posting for same issue to change the prefix for the control to "ef" then my Entitydatasouce smart tag disable. I'm a beginner and want to try to learn Entity Framework but got stuck here. 

    Highly appreciate if  anyone know how to fix these problems!!

    Thanks in advance! 

    Thursday, December 31, 2020 4:04 AM

All replies

  • User753101303 posted

    Hi,

    You are still trying to use the wizard? A bit ambigious but my understanding is that if not using EF5 you must update the package AND edit markup on the page rather than using the wizard.

    Also rather than using the EntityDataSource contril, I would suggest to have a look at Retrieving and displaying data with model binding and web forms | Microsoft Docs which seems not well known (being one of the latest change made to binding controls and data in Web Forms) and closest to what is done currently with MVC or WebPages (ie just using .NET classes as your data source)...

    Edit: beginner to EF and familiar with Web Forms or new as well to Web Forms? Web Forms is not carried forward to ASP.NET Core which is basically a cross platform reboot of ASP..NET 4.x. Unless you know already Web Forms and want to keep using it for the time being, it would be better to learn about MVC or WebPages. For example Comparing ASP.NET Core Razor Pages with MVC - Espresso Coder

    Thursday, December 31, 2020 10:20 AM
  • User291446270 posted

    @PatriceSc ---Thanks for your advices. Yes, I'm beginner to EF and kind of more familiar to Web Forms as I learn ASP.Net Web application. I was thinking to start learning Entity Framework but It seem like I can't proceed as I don't know how to do the markup on the page.  I might learn something else like MVC or webpages. Thanks for your sharing. "HAPPY NEW YEAR"!

    Friday, January 1, 2021 2:48 AM
  • User1535942433 posted

    Hi QPeople,

    I was thinking to start learning Entity Framework but It seem like I can't proceed as I don't know how to do the markup on the page. 

    As far as I think,the default <asp:EntityDataSource> doesn't support EF 6. We no longer recommend using the Entity Data Source for new projects, so we just did the work to provide a data source that is usable with EF6. You need to write a model in <asp:EntityDataSource> and you could bind the model in your codes.

    Best regards,

    Yijing Sun

    Friday, January 1, 2021 5:21 AM
  • User291446270 posted

    @Yijing Sun---Thanks for your comment. I haven't tried on the Model first approach from the entity framework, I would like to learn that as well eventually. I found a solution to the issue I posted. That allows me to proceed to my learning although I'm not sure if that applies in the real working environment as you and others did mention the EntityDataSource doesn't support EF6. Here, I would like to share my solution. I downgrade my EF6 to EF5. To do that, I uninstalled my EF6 from my project and reinstalled it to EF5. Before that, I have a problem looking for Entity Framework 5 from Nudget online galleries/browse because if you search Entity Framework--it will come out the latest version of Entity Framework 6.4. At last, I notice there is a version selection dropdown list beside the install button so I can choose the Entity Framework version 5. Since the EntityDataSource is only working with EF5 then I have solved this problem. 

    Saturday, January 2, 2021 2:56 AM
  • User753101303 posted

    Then I would really consider using https://docs.microsoft.com/en-us/aspnet/web-forms/overview/presenting-and-managing-data/model-binding/retrieving-data

    In short you can bind data controls to CRUD methods working on .NET objects which are handled for example using EF without using an intermediate control such as an EntityDataSource.

    Saturday, January 2, 2021 10:32 AM
  • User291446270 posted

    @PatriceSc--Thanks again and the link you provided. I have had a look at it and appreciated it.

    Sunday, January 3, 2021 9:28 AM