dbcontext source for radgrid on EF6

3 posts, 1 answers
  1. Daniel
    Daniel avatar
    16 posts
    Member since:
    Jun 2013

    Posted 20 Feb 2014 Link to this post

    Hello people,

    I have coded my EF5 dbcontext RadGrid datasource as this:

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

    <asp:EntityDataSource ID="edsMainGrid" runat="server" 

    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. Answer
    Radoslav avatar
    1566 posts

    Posted 25 Feb 2014 Link to this post

    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.

    I hope this helps.  

    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.
  3. Daniel
    Daniel avatar
    16 posts
    Member since:
    Jun 2013

    Posted 23 Apr 2014 in reply to Radoslav Link to this post

    Fixed by MS on Feb'2014

    Install Package Microsoft.AspNet.EntityDataSource:

    PM> Install-Package Microsoft.AspNet.EntityDataSource


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

Back to Top