I'm looking at using the new Geography types in Entity Framework 5 and 6 for my next project - see this tutorial link http://msdn.microsoft.com/en-us/data/jj250903.aspx
I've created a MyProject.Entities Visual Studio library project containing my entity models. The problem that I foresee is that I would need to reference Entity Framework 5+ in the MyProject.Entities project in order to use the DbGeography
type that corresponds to the geography
column in my SQL Server database when mapping this using Entity Framework (or at least that appears to be the case based on the instructions in the tutorial link above). I'd prefer not to directly reference the Entity Framework in my MyProject.Entities project since I'm planning to share this library across several project which may be using different versions of Entity Framework. In terms of style, I'd also like to keep the MyProject.Entities project as simple and clean as possible - coupling my entities project to the Entity Framework seems ugly by this criteria.
Here is 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 get around it?
EDIT: I thought of a good way to articulate my concern. The new OWIN identity model provides interfaces like IUser
so that developers can write their own implementations without referencing the Entity Framework directly, e.g. https://code.msdn.microsoft.com/Simple-Aspnet-Identiy-Core-7475a961. Unfortunately DbGeography
doesn't seem to implement such an interface http://referencesource.microsoft.com/#System.Data.Entity/System/Data/Spatial/DbGeography.cs so I'm stuck referencing the Entity Framework.