I've put together a .Net 5 for Windows application, using among other things EntityFramework 5.0.13.
Now we're trying to run it on a specific server, that doesn't have the .Net 5 framework yet. The nice people who admin the server tell me that they've tried to install new things, but can't seem to make the application run. Restarting the server might be necessary, which cannot be done for the time being.
So I need to use an older target framework for my application. Fine, so I decided to target multiple frameworks, adding .Net Framework 4.8 as well. In my .csproj file, that amounts to replacing
<TargetFramework>net5.0-windows</TargetFramework>
with
<TargetFrameworks>net5.0-windows;net48</TargetFrameworks>
and that should do the trick.
Unfortunately, EntityFramework 5.0.13 is not compatible with .Net Framework 4.8.
So I used an older version, 3.1.9 (that works fine on another of our projects).
It took a bit of convincing, but now my project uses 3.1.9. (And I trust that it will build fine once I downgrade a few Class variable = new();
and if (variable is not null)
statements.)
Now, what I'm wondering about is, can I get my .Net 5 target framework to use EntityFramework 5.0.13 again instead of 3.1.9?
Right now, my .csproj file reads
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.9" />
Before I started to use multiple target frameworks, that was
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.13" />
Is there a way to add an attribute to PackageReference
(or replace it with another node) so it only targets a specific framework?