Chaining form EF 4 to EF 6

9 posts, 2 answers
  1. Uwe
    Uwe avatar
    49 posts
    Member since:
    Sep 2012

    Posted 08 Oct 2014 Link to this post

    Hello Telerik,

    is the a way to use a QueryableEntityCollectionView object (bounded to a RadGridView) with EF6 which has a DBContext instate of ObjectContext?
    I'm chaining my Telerik application form EF 4 to EF 6.
    Or can you give me a link to a simple GridView example using Entity Framework 6?

    Regards Uwe
  2. Answer
    Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 09 Oct 2014 Link to this post

    Hi Uwe,

    You should not have problems populating RadGridView with data using EF6. You can check the RadEntityFrameworkDataSource examples in our WPF Demos for a reference.

    Please note that in case you get RadEntityFrameworkDataSource to work with EF6, you should reference the Telerik.Windows.Controls.EntityFramework60 assembly.

    Regards,
    Dimitrina
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. Uwe
    Uwe avatar
    49 posts
    Member since:
    Sep 2012

    Posted 28 Oct 2014 in reply to Dimitrina Link to this post

    Hello Dimitrina thank you for answering. 

    I tried the EntityFrameworkDataSourceExample in the new demos for 2014 Q3, I ported it to a small own WPF app and it works fine. But I have still this problem. Which crash my application (or any other exception from the sql server). Except I catch the exception in OnDispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e) in App.xaml.cs. What is also not a good solution.
    So is their any possibility to catch the sql exception on a better place, or is it, in this case, necessary to build a n-tier architecture or something like that?

    Thank you for your effort
  4. Uwe
    Uwe avatar
    49 posts
    Member since:
    Sep 2012

    Posted 30 Oct 2014 in reply to Uwe Link to this post

    OK, after clearing the solution and making a new build, all demos works correct! 
  5. Uwe
    Uwe avatar
    49 posts
    Member since:
    Sep 2012

    Posted 30 Oct 2014 in reply to Uwe Link to this post

    Sorry for the mix-up. The last post in in the wrong thread and in the penultimate post is a ':' missing in the link. So the correct link is http://www.telerik.com/forums/unhandled-entitycommandexecutionexception.
  6. Uwe
    Uwe avatar
    49 posts
    Member since:
    Sep 2012

    Posted 23 Jan 2015 Link to this post

    Hello Dimitrina,

    RadEntityFrameworkDataSource is an UI-Element and Works fine in a non MVVM environment. Referring to my first post I'm using QueryableEntityCollectionView in my projects and link it withe the ObjectContext of my Entities. Microsoft removed the ObjectContext in EF 6. In the regular Telerik Demo I can not find an example for the RadGridView using EF 6 in MVVM.
    So maybe is there a is there another example?

    Regards Uwe

  7. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 27 Jan 2015 Link to this post

    Hi Uwe,

    Following the demo for MVVM support of RadEntityFrameworkDataSource, there should be no difference when using EF4 or EF6. If you need to get the context, you should use DbContext instead.
    What are the difficulties that you encountered when using this approach with EF6 ? 

    Regards,
    Maya
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  8. Uwe
    Uwe avatar
    49 posts
    Member since:
    Sep 2012

    Posted 20 Feb 2015 in reply to Maya Link to this post

    Hello Maya, 

    thank you for helping, my be the misunderstanding is that my data source is in the ViewModel! But I think I solved the problem well, doing this:

    private ObjectContext oC;
    ...
    private QueryableEntityCollectionView<BAMeasurement> bAMeasurements;
    ...
        
    BAEntities BAEntitiesObj = new BAEntities(_msdb.GetSQLConnectionStringFromProperties());
    oC = ((IObjectContextAdapter)BAEntitiesObj).ObjectContext;
    bAMeasurements = new QueryableEntityCollectionView<BAMeasurement>(oC, "BAMeasurements");


    were BAEntities is driven from DbContext

    But for this it is necessary to use .Net 4.5

    Regards Uwe
  9. Answer
    Maya
    Admin
    Maya avatar
    4062 posts

    Posted 20 Feb 2015 Link to this post

    Hi Uwe,

    Glad to see you resolved the issue. Let me know if you need further assistance.


    Regards,
    Maya
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top