Using SQL Server Geography in C # Objects without referencing Entity Framework

I am considering using the new geography types in Entity Framework 5 and 6 for my next project - see this link http://msdn.microsoft.com/en-us/data/jj250903.aspx

I created a Visual Studio library project MyProject.Entities that contains my entity models. The problem I foresee is that I will need to reference Entity Framework 5+ in the MyProject.Entities project in order to use the type DbGeography

that matches the columngeography

in my SQL Server database when mapping using Entity Framework (or at least this seems to be based on the instructions in the link above). I would rather not link directly to the Entity Framework in my MyProject.Entities project, as I plan to share this library across multiple projects that may be using different versions of the Entity Framework. In terms of styling, I'd also like to keep the MyProject.Entities project as simple and clean as possible - my objects project's interaction with the Entity Framework seems ugly by these criteria.

Here's a simplified example of one of my models:

namespace MyProject.Entities
{
    public class PointOfInterest
    {
        public int Id { get; set; }
        public string Name { get; set; }
        public DbGeography Geo { get; set; }
    }
}

      

Has anyone else had this concern? If so, how did you manage?

EDIT: I was thinking of a good way to frame my concern. The new OWIN identity model provides interfaces such as IUser

so that developers can write their own implementations without referencing the Entity Framework directly, eg. https://code.msdn.microsoft.com/Simple-Aspnet-Identiy-Core-7475a961 . Unfortunately, DbGeography

it doesn't seem to implement such an interface http://referencesource.microsoft.com/#System.Data.Entity/System/Data/Spatial/DbGeography.cs , so I am stuck referencing Entity Framework.

+3


source to share


1 answer


Perhaps you can just use

Microsoft.SqlServer.Types.SqlGeography

      



http://msdn.microsoft.com/en-us/library/microsoft.sqlserver.types.sqlgeography.aspx

+1


source







All Articles