Entity Framework cannot update database

c# entity-framework

Question

My application crashes with the following error whenever I save to the DB.

Unable to find an entry point named 'SetClrFeatureSwitchMap' in DLL 'SqlServerSpatial110.dll'.

This error started yesterday afternoon after a Windows Update and PC Reboot. The dll is not referenced in the project and is not in the bin folder.

I use EF5 and I can connect to the DB and pull data but when I call ObjectContext.SaveChanges() the error occurs.

The application does not use geometry, so I have no idea where this is coming from.

1
34
1/21/2016 6:54:37 PM

Accepted Answer

I had the same issue, and fixed it by adding the following lines to the web.config of my application:

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

This forces the EntityFramework to use the version 10 of the SqlServer.Types.dll, which doesn't have the Geometry type apparently.

73
12/23/2015 8:11:52 AM

Popular Answer

So, If I add the following line of code to the start-up of the application it will use the SQL 2014 version of the Microsoft.SqlServer.Types assembly which doesn't seem to have the problem stated above.

System.Data.Entity.SqlServer.SqlProviderServices.SqlServerTypesAssemblyName = "Microsoft.SqlServer.Types, Version=12.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91";

This is fine for machines that have SQL Server 2014 SDK installed.

I have also submitted a bug with Microsoft here:

https://connect.microsoft.com/SQLServer/Feedback/Details/2139143



Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow