none
EF 6 and DbGeography RRS feed

  • Question

  • I am using VS 2013 and generate entity classes. One of the table has a column data type of "Geography". After build, there is an error of "System.Data.Spatial.DbGeography not reference". However, when I change it to "System.Data.Entity.Spatial.DbGeography", it build successfully.

    I understand the System.Data.Entity is included in framework.dll.

    Thus, how do I avoid the above error without manual change the namespace of the data type being generated by VS2013?

    Regards

    Wednesday, January 29, 2014 4:53 PM

Answers

All replies

  • Hello,

    Have a try to below steps:

    1. Removing assembly references to System.Data.Entity.dll

    2. Installing the EF6 NuGet package adds the following runtime assemblies to the project:

    3. Recent builds of the EF6 NuGet package removes reference to System.Data.Entity.dll from the project.

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, January 30, 2014 3:15 AM
    Moderator
  • There is no reference to the System.Data.Entity dll.

    I removed framework.dll and re-get the Framework 6.0 from NuGet. However, the same error in compilation.

    Any other suggestion?

    Regards

    Thursday, January 30, 2014 2:31 PM
  • Since the namespace has already there, the VS cannot remove it automaticly, we have replace it by hand.
    Monday, February 3, 2014 9:34 AM
  • Is this MS Bug or otherwise? How VS pick up wrong dll for resolution?
    Monday, February 3, 2014 2:23 PM
  • >> Is this MS Bug or otherwise? How VS pick up wrong dll for resolution?

    No, in Entity Framework 6, DbGeography is moved from System.Data.Spatial in System.Data.Entity.dll to System.Data.Entity.Spatial in EntityFramework.dll.

    http://msdn.microsoft.com/en-us/library/system.data.spatial.dbgeography(v=vs.110).aspx

    http://msdn.microsoft.com/en-us/library/system.data.entity.spatial.dbgeography(v=vs.113).aspx


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, February 4, 2014 8:34 AM
    Moderator
  • I understand but why VS not resolving DbGeography from framework.dll rather than from system.data which the data type is not there?
    Tuesday, February 4, 2014 2:44 PM
  • System.Data.Spatial.DbGeography and System.Data.Entity.Spatial.DbGeography are different types.  They happen to have similar names and identical behavior, but they are different types.

    EF6 copied some code into new namespaces to decouple it from the .NET Framework types.  If your app is targeting EF6 our source code should only reference System.Data.Entity.Spatial.DbGeography.

    If you have hand written references to System.Data.Spatial.DbGeography, change them.  Otherwise find where they are being generated.  It's possible you aren't using the right version of the code generation templates.

    David


    David http://blogs.msdn.com/b/dbrowne/

    Tuesday, February 4, 2014 3:34 PM
  • I follow this article

    http://msdn.microsoft.com/en-US/data/dn469466

    Everything is resolved now.

    Thanks

    Tuesday, February 4, 2014 5:40 PM