'Microsoft.SqlServer.Types' version 10 or higher could not be found on Azure

前端 未结 12 2320
感情败类
感情败类 2020-11-30 23:01

I\'m trying to make a webapi in ASP.NET MVC 4. The webapi used Entity Framework 5 Spatial types and i have wrote a very simple code.

  public List

        
相关标签:
12条回答
  • 2020-11-30 23:53

    In my case (a WebForms App) I solved the problem adding the following lines in the Application_Start of the Global.asax file.

    SqlServerTypes.Utilities.LoadNativeAssemblies(Server.MapPath("~/bin"));
    System.Data.Entity.SqlServer.SqlProviderServices.SqlServerTypesAssemblyName = "Microsoft.SqlServer.Types, Version=14.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91";
    

    I hope it helps someone.

    0 讨论(0)
  • 2020-11-30 23:56

    I found the solution ! Just install the nuget package Microsoft.SqlServer.Types

    PM> Install-Package Microsoft.SqlServer.Types

    Link for more info

    0 讨论(0)
  • 2020-11-30 23:58

    For some reason I was missing a binding redirect which fixed this problem for me.

    Adding the following fixed my problem

        <dependentAssembly>
          <assemblyIdentity name="Microsoft.SqlServer.Types" publicKeyToken="89845dcd8080cc91" culture="neutral" />
          <bindingRedirect oldVersion="10.0.0.0-11.0.0.0" newVersion="14.0.0.0" />
        </dependentAssembly>
    
    0 讨论(0)
  • Please add "dependentAssembly" the Web.config file

    <runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
            <dependentAssembly>
                <assemblyIdentity name="Microsoft.SqlServer.Types" publicKeyToken="89845dcd8080cc91" culture="neutral" />
                <bindingRedirect oldVersion="0.0.0.0-14.0.0.0" newVersion="14.0.0.0" />
            </dependentAssembly>
        </assemblyBinding>
    </runtime>
    

    This worked for me

    0 讨论(0)
  • 2020-12-01 00:03

    Following a comment in an answer for current post, adding these two lines (preferebly to the main function) solved my problem for Console App:

    SqlProviderServices.SqlServerTypesAssemblyName = typeof(SqlGeography).Assembly.FullName;
    SqlServerTypes.Utilities.LoadNativeAssemblies(AppDomain.CurrentDomain.BaseDirectory);
    
    0 讨论(0)
  • 2020-12-01 00:07

    In my case, a badly composed connection string caused this. Verify if your connection string is properly composed.

    0 讨论(0)
提交回复
热议问题