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

dbcontext source for radgrid on EF6

2 Answers 100 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Daniel
Top achievements
Rank 1
Daniel asked on 20 Feb 2014, 09:05 PM
Hello people,

I have coded my EF5 dbcontext RadGrid datasource as this:

<telerik:RadGrid ID="RadGrid1"
          runat="server"
          CellSpacing="0" DataSourceID="edsMainGrid"
...

<asp:EntityDataSource ID="edsMainGrid" runat="server" 
                            OnContextCreating="edsMainGrid_ContextCreating"
                            EntitySetName="myCollection">
</asp:EntityDataSource>

Protected Sub edsMainGrid_ContextCreating(sender As Object, e As EntityDataSourceContextCreatingEventArgs)
        Dim ctx As myEntities = myEntities()
        e.Context = TryCast(ctx, IObjectContextAdapter).ObjectContext
End Sub


and all runs fine in EF5 but ....


... I'm migrating to EF6. And, as you know, they are several namespaces ported to EntityFramework.dll.

My issue is, than, in EF6, an error is raised in this line of code:

e.Context = TryCast(ctx, IObjectContextAdapter).ObjectContext

The issue is than e.Context and TryCast(ctx, IObjectContextAdapter).ObjectContext, both are ObjectContext objects, the same type, but declared in separate namespace. The error “Value of type 'System.Data.Objects.ObjectContext' cannot be converted to 'System.Data.Entity.Core.Objects.ObjectContext'“ occurs.

My question:

What is the right way to set dbcontext datasource for radgrind in EF6?



thanks in advance!






2 Answers, 1 is accepted

Sort by
0
Accepted
Radoslav
Telerik team
answered on 25 Feb 2014, 01:04 PM
Hi Daniel,

The described error is general and it is not related with our controls. Please check out the following forum threads which elaborate on the same matter.
http://stackoverflow.com/questions/14106286/ef-6-system-data-objects-objectcontext-error
http://social.msdn.microsoft.com/Forums/en-US/4ad7ee84-3b73-4cb5-870c-2b5bd7b85ed4/cannot-implicitly-convert-type-systemdataentitycoreobjectsobjectresultstring-to?forum=adodotnetentityframework
http://www.devexpress.com/Support/Center/Question/Details/Q539957
https://entityframework.codeplex.com/workitem/806
http://forums.asp.net/t/1877091.aspx?Tell+me+if+I+am+doing+it+wrong

I hope this helps.  

Regards,
Radoslav
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the UI for ASP.NET AJAX, subscribe to the blog feed now.
0
Daniel
Top achievements
Rank 1
answered on 23 Apr 2014, 10:00 AM
Fixed by MS on Feb'2014

Install Package Microsoft.AspNet.EntityDataSource:

PM> Install-Package Microsoft.AspNet.EntityDataSource

http://www.nuget.org/packages/Microsoft.AspNet.EntityDataSource/

And change signature handler to:
Protected Sub edsMainGrid_ContextCreating(sender As Object, e As Microsoft.AspNet.EntityDataSource.EntityDataSourceContextCreatingEventArgs)




Tags
General Discussions
Asked by
Daniel
Top achievements
Rank 1
Answers by
Radoslav
Telerik team
Daniel
Top achievements
Rank 1
Share this question
or