In my .NET CORE project, I'm using layered structure and for Spatial Types I am using
dotMorten.Microsoft.SqlServer.Types Version="1.1.0"
Here are my .csproj files:
Entities.csproj :
<ItemGroup>
<PackageReference Include="dotMorten.Microsoft.SqlServer.Types" Version="1.1.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.5" />
<PackageReference Include="Microsoft.Extensions.Identity.Stores" Version="3.1.5" />
<PackageReference Include="System.Data.SqlClient" Version="4.8.1" />
</ItemGroup>
DataAccess.csproj :
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Hosting.Abstractions" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Http.Features" Version="3.1.5" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="3.1.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.1.5">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.1.5">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="NLog" Version="4.7.2" />
<PackageReference Include="Npoi.Mapper" Version="3.4.0" />
<PackageReference Include="System.Data.SqlClient" Version="4.8.1" />
</ItemGroup>
WebUI.csproj : --> ASP.NET CORE
<ItemGroup>
<PackageReference Include="itext7" Version="7.1.11" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.1.5">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.1.5">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.3" />
<PackageReference Include="NLog" Version="4.7.2" />
<PackageReference Include="NLog.Web.AspNetCore" Version="4.9.2" />
<PackageReference Include="Scrutor" Version="3.2.1" />
<PackageReference Include="System.Data.SqlClient" Version="4.8.1" />
</ItemGroup>
I have tried below:
Install Microsoft.SqlServer.Types package from Nuget
Create a web.config file and add :
<runtime>
<dependentAssembly>
<assemblyIdentity name="Microsoft.SqlServer.Types" publicKeyToken="89845dcd8080cc91" />
<bindingRedirect oldVersion="10.0.0.0" newVersion="14.0.0.0" />
</dependentAssembly>
</runtime>
- Before dotMorten's Nuget package, I was using
EntityFrameworkCore.SqlServer.HierarchyId
package, but at that time period, I was having a "Constructor" exception for HierarchyId while I was creating a migration, so I've decided to use dotMorten's package.
Thanks in advance.
NOTE FOR READERS
Since I couldn't solve this problem,
I am back to using
EntityFrameworkCore.SqlServer.HierarchyId
since migration support has been fixed in v1.1 and is now available in Nuget.EntityFrameworkCore.SqlServer.HierarchyId
running without errors in .NET CoreFor Your Information: I will not accept this as the correct answer, because this answer is not providing any information about the main issue!