0

I'm working in Entity Framework 6 for the first time. I downloaded the tutorial and used it to start my program. I'm using Entity Framework as a method of connecting to two different servers to pull data and store them in variables. I followed the tutuorial exactly and have it set up the exact same way. Below is what I have so far in the main module. If there's anything else you need to see, let me know. Hope this is enough info. Thanks!

    JobCodesContext = New LicensingRepository_DvlpEntities1

    Dim JobCodeQuery As ObjectQuery(Of ControlTrackedJobCode) =
        From Element In JobCodesContext.ControlTrackedJobCodes.Include("JobCode")
        Select Element
mwell10
  • 9
  • 1
  • Possible duplicate of [Entity Framework 4.1: Unable to cast from DbQuery to ObjectQuery](http://stackoverflow.com/questions/7208709/entity-framework-4-1-unable-to-cast-from-dbquery-to-objectquery) – Lukas Kabrt Nov 06 '15 at 16:30
  • Potentially Lukas, but I don't know C#. Even though they are similar languages, I can't tell how that solution would help me. – mwell10 Nov 06 '15 at 17:00

1 Answers1

0

The answer from the similar question converted to VB

Dim objectContext As ObjectContext = 
    CType(JobCodesContext, IObjectContextAdapter).ObjectContext;

Dim JobCodeQuery As ObjectQuery(Of ControlTrackedJobCode) =
        From Element In objectContext.CreateObjectSet(Of ControlTrackedJobCode).Include("JobCode")
        Select Element
Community
  • 1
  • 1
Lukas Kabrt
  • 5,441
  • 4
  • 43
  • 58
  • Thanks Lukas! I get the following error message: "'controlTrackedJobCodes is not a member of System.Data.Entity.Core.Objects" How do I add ControlTrackedJobCodes to System.Data.Entity.Core.Objects.Objectcontext? – mwell10 Nov 06 '15 at 18:58
  • Try using `CreateObjectSet(Of ControlTrackedJobCode)` instead of `ControlTrackedJobCodes` ... not sure about the correct syntax in VB – Lukas Kabrt Nov 06 '15 at 19:50
  • If it solved your problem, please accept the answer - http://stackoverflow.com/help/someone-answers – Lukas Kabrt Nov 06 '15 at 20:48