This is a migrated thread and some comments may be shown as answers.

Chaining form EF 4 to EF 6

7 Answers 104 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Uwe
Top achievements
Rank 1
Uwe asked on 08 Oct 2014, 06:03 AM
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

7 Answers, 1 is accepted

Sort by
0
Accepted
Dimitrina
Telerik team
answered on 09 Oct 2014, 07:57 AM
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.

 
0
Uwe
Top achievements
Rank 1
answered on 28 Oct 2014, 07:03 PM
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
0
Uwe
Top achievements
Rank 1
answered on 30 Oct 2014, 11:44 AM
OK, after clearing the solution and making a new build, all demos works correct! 
0
Uwe
Top achievements
Rank 1
answered on 23 Jan 2015, 08:19 AM
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

0
Maya
Telerik team
answered on 27 Jan 2015, 11:33 AM
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.

 
0
Uwe
Top achievements
Rank 1
answered on 20 Feb 2015, 06:52 AM
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
0
Accepted
Maya
Telerik team
answered on 20 Feb 2015, 08:07 AM
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.

 
Tags
GridView
Asked by
Uwe
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Uwe
Top achievements
Rank 1
Maya
Telerik team
Share this question
or