Reputation: 2580
I have an Azure V3 app that must call DAL repos built on Entity Framework 6.4 On database initialize I am getting an exception:
System.Data.SqlClient: System.Data.SqlClient is not supported on this platform
That is coming from: System.Data.SqlClient
4.8
public sealed partial class SqlConnection : System.Data.Common.DbConnection, System.ICloneable
{
public SqlConnection()
{
throw new System.PlatformNotSupportedException(System.SR.PlatformNotSupported_DataSqlClient)
}
}
In similar threads the resolution was to downgrade System.Data.SqlClient
to version 4.5.1, but in my case the dependency being added by Entity Framework.
Anyone having an idea if it is possible to use Entity Framework 6.4 in Azure function V3 app?
Upvotes: 3
Views: 1024
Reputation: 20067
It seems that it's still a .NET Core 3.0 SDK bug and the following is workaround you could refer to.
Right click on Function project and edit <FunctionAppName>.csproj
, add items below to copy related assemblies to output dir.
<ItemGroup>
<None Include="$(USERPROFILE)\.nuget\packages\system.data.sqlclient\4.6.0\runtimes\win\lib\netcoreapp2.1\System.Data.SqlClient.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
If you'd like to stilluse the .NET Core 3.0 SDK, or need this fix for Functions v3 as well:
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<!-- https://github.com/Azure/azure-functions-host/issues/3568#issuecomment-461182536 -->
<Exec Command="copy $(OutDir)$(ProjectName).deps.json $(OutDir)bin\function.deps.json" />
</Target>
<Target Name="PostPublish" BeforeTargets="Publish">
<!-- https://github.com/Azure/azure-functions-host/issues/3568#issuecomment-461182536 -->
<Exec Command="copy $(PublishDir)$(ProjectName).deps.json $(PublishDir)bin\function.deps.json" />
<!-- https://github.com/Azure/azure-functions-vs-build-sdk/issues/333 -->
<Exec Command="move $(PublishDir)\runtimes $(PublishDir)\bin" />
</Target>
Upvotes: 3