Search code examples
c#entity-framework-6asp.net-4.5sql-server-2016-localdb

Entity Framework C# - DbGeometry POLYGON doesn't work


i have a problem with WKT and DbGeometry working together. When i use POINT as geometry like this example it works good.

DbGeometry myGeometry1 = DbGeometry.FromText("POINT (30 10)");
DbGeometry myGeometry2 = DbGeometry.PointFromText("POINT (30 10)", 0);

if i use POLYGON or any other geometry instead, it doesn't work at all.

DbGeometry myGeometry3 = DbGeometry.FromText("POLYGON ((30 10, 40 40, 20 40, 10 20, 30 10))");
DbGeometry myGeometry4 = DbGeometry.PolygonFromText("POLYGON ((30 10, 40 40, 20 40, 10 20, 30 10))", 0);

This is the Platform Stack:

Entity Framework 6 ASP.NET 4.5 SQLServer 2016 LocalDB


Solution

  • Just install SQLSysClrTypes_x86.msi and SQLSysClrTypes_x64.msi

    from Microsoft SQL Server 2016 Feature Pack

    https://www.microsoft.com/en-us/download/details.aspx?id=52676