title: How to correct Polygon Ring Orientation using C# Entity Framework 5 DbGeography Spatial Data
body: <p>I'm working with the new Entity-Framework 5 using the Spatial data type DbGeography as part of my model for storing in one instance, a POINT and in another instance a POLYGON.</p>
  
  <p>When setting the value of my POLYGON all saves with no error however this is only the case if I draw the Polygon on the map in a clockwise order. If I draw the POLGON in an anti-clockwise direction I get an error the the sql level indicating that the data is an invalid geography type.</p>
  
  <p>Now after doing my own research into the problem, it appears to stem from the geography data type being quite strict in terms of a Polygons ring orientation. The most common solution appears to be creating the Polygon as a geometry and then converting it to a geography type.</p>
  
  <p>I am looking for a solution in C# that can be applied to the data before it gets sent to sql. Basically something that will auto correct the ring orientation of an array of coordinates. </p>
  
  <p>I have tried catching the error and then rebuilding the string by reversing the array. This works in some cases but firstly it's not reliable and secondly catching the error is to big a performance hit.</p>
  
  <p>Thanks
  Chris</p>