title: Multiple target framework project: different versions of the same NuGet package on different frameworks?
body: <p>I've put together a .Net 5 for Windows application, using among other things EntityFramework 5.0.13.</p>
  <p>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.</p>
  <p>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</p>
  <pre class="lang-xml prettyprint-override"><code>    &lt;TargetFramework&gt;net5.0-windows&lt;/TargetFramework&gt;
  </code></pre>
  <p>with</p>
  <pre class="lang-xml prettyprint-override"><code>    &lt;TargetFrameworks&gt;net5.0-windows;net48&lt;/TargetFrameworks&gt;
  </code></pre>
  <p>and that should do the trick.</p>
  <p>Unfortunately, EntityFramework 5.0.13 is not compatible with .Net Framework 4.8.</p>
  <p>So I used an older version, 3.1.9 (that works fine on another of our projects).</p>
  <p>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 <code>Class variable = new();</code> and <code>if (variable is not null)</code> statements.)</p>
  <p>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?</p>
  <p>Right now, my .csproj file reads</p>
  <pre class="lang-xml prettyprint-override"><code>    &lt;PackageReference Include=&quot;Microsoft.EntityFrameworkCore&quot; Version=&quot;3.1.9&quot; /&gt;
  </code></pre>
  <p>Before I started to use multiple target frameworks, that was</p>
  <pre class="lang-xml prettyprint-override"><code>    &lt;PackageReference Include=&quot;Microsoft.EntityFrameworkCore&quot; Version=&quot;5.0.13&quot; /&gt;
  </code></pre>
  <p>Is there a way to add an attribute to <code>PackageReference</code> (or replace it with another node) so it only targets a specific framework?</p>