Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

222
Visualizações
Is it a good idea to target both ef core 3.1 and 5?

I have a small nuget package that interacts with a small DB with 2 tables. I have used it in 2 projects, 1 is dotnet 5 and the other is an old dotnet framework 4.6 therefore I have targeted netstandard2.0 and it worked fine so far.

I need to update all the packages in the dotnet 5 one to the latest, but ef core 5 needs dotnet standard 2.1. What is the best way to deal with it?

I thought about multi targeting, but first I don't know if it is a good idea or not and then I don't know how to say target dot net standard 2.1 with ef 5 and at the same time dotnet standard 2 with the ef 3.1.

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

Targeting multiple versions of EF Core (or any other package) can be OK, but bear in mind that it's going to affect the maintainability of the package, so only you can decide if it's worth it or not.

  • Are you going to benefit from any specific feature/performance improvement of EF Core 5?
  • Are different behaviors acceptable for you and your users? If not, revisit the previous point because you may need to tweak your code to achieve that, ignoring some EF Core 5 add-ons.
  • etc.

Regarding the implementation:

You can solve the project references issue by using Condition at ItemGroup level and checking the value of $(TargetFramework).

<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
    <PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.13" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' != 'netstandard2.0' ">
    <PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.4" />
</ItemGroup>

In your C# code you'll need to make use of preprocessor directives (#if NETSTANDARD2_0) to differentiate both implementations.

You can read more detailed documentation about both .csproj and C# solutions here.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda