Enrico
Enrico

Reputation: 6202

Azure Functions and the new version of Microsoft.Data.SqlClient: is not supported on this platform

In my Azure Functions, I'm using Microsoft.EntityFrameworkCore version 3.1.4. Today I decided to update the nuget packages and I updated it to 3.1.5. Also, I updated the following packages:

<PackageReference Include="AzureExtensions.Swashbuckle" Version="3.2.2" />
<PackageReference Include="Microsoft.Azure.Storage.Blob" Version="11.1.7" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.ServiceBus" 
                  Version="4.1.2" />
<PackageReference Include="Microsoft.Extensions.Configuration.AzureKeyVault" 
                  Version="3.1.5" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="3.0.8" />

<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.1.5">

I'm using a .NET Core 3.1

<PropertyGroup>
  <TargetFramework>netcoreapp3.1</TargetFramework>
  <AzureFunctionsVersion>v3</AzureFunctionsVersion>
</PropertyGroup>

Now, in my machine, I have this error:

Microsoft.Data.SqlClient is not supported on this platform.

The error occurs when I try to create new SqlParameters.

SqlParameter[] parameters = new SqlParameter[2];
parameters[0] = new SqlParameter("@todayOnly", SqlDbType.Bit) { Value = todayOnly };

I tried to downgrade to the previous version but now I receive the same error.

I saw other posts, like this one but I don't think it is the solution.

Upvotes: 1

Views: 721

Answers (1)

ErikEJ
ErikEJ

Reputation: 41749

It is a bug in Microsoft.NET.Sdk.Functions 3.0.8.

see https://github.com/Azure/azure-functions-vs-build-sdk/issues/436

workaround is to downgrade to 3.0.7

Upvotes: 1

Related Questions