locked
Error Trying to run Function with Entity Spatial... RRS feed

  • Question

  • Have a very simple Function that compiles fine but has Problems with Entity Framework when it attempts to run in Visual Studio. Here is the code. What is going on here? Thanks in Advance. 

    using System;
    using Microsoft.Azure.WebJobs;
    using Microsoft.Azure.WebJobs.Host;
    using System.Data;
    using System.Data.Entity.Spatial;
    
    namespace SpatialTestFunction
    {
        public static class Function1
        {
            [FunctionName("Function1")]
            public static void Run([TimerTrigger("0 */1 * * * *")]TimerInfo myTimer, TraceWriter log)
            {
    
              // Create a GeometryPolygon.
               DbGeometry testPoly = System.Data.Entity.Spatial.DbGeometry.PolygonFromText("POLYGON((127.652 -26.244,127.652 -26.194,127.652 -26.244))", 4326);
    
    
              DbGeometry Centroid =   testPoly.Centroid ;
               
                log.Info($"C# Timer trigger function executed at: {DateTime.Now}");
            }
        }
    }

    Thursday, November 22, 2018 12:23 AM

All replies

  • Which version of Azure functions are you running v1 or v2?
    Thursday, November 22, 2018 2:09 AM
  • Am running version 2
    Thursday, November 22, 2018 1:06 PM
  • hello,

    I think that it is related to the fact that System.Data.Entity.Spatial is not supported by .Net Standard 2.1, and thus you should migrate to Microsoft.Spatial library here is a SO Thread about the migration.

    Hope it helps!

    Good Coding;

    Friday, November 23, 2018 11:02 PM