title: .Net - add migration command invalidates NuGet package
body: <p>I have installed the latest version of Microsoft.EntityFrameworkCore, have my models set up, have the context set up and have added the context to my startup.cs file. But when I run the command &quot;dotnet ef migrations add InitialCreate&quot;, it says starts the build and then stops, with the following message &quot;Build started...Build failed. Use dotnet build to see the errors.&quot;</p>
  <p>Then it seems to invalidate the recently installed NuGet package, Microsoft.EntityFrameworkCore, saying it cannot find it and cannot link any of its related syntax (red lines appear beneath all the related code again). This is despite properly installing the package previously.</p>
  <p>The following errors are given:</p>
  <pre><code>
      Data\EventContext.cs(5,17): error CS0234: The type or namespace name 'EntityFrameworkCore' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?) [C:\Users\USER\source\repos\EventPlanner\EventPlanner\EventPlanner.csproj]
      Data\EventContext.cs(10,33): error CS0246: The type or namespace name 'DbContext' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\USER\source\repos\EventPlanner\EventPlanner\EventPlanner.csproj]
      Data\EventContext.cs(16,16): error CS0246: The type or namespace name 'DbSet&lt;&gt;' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\USER\source\repos\EventPlanner\EventPlanner\EventPlanner.csproj]
      Data\EventContext.cs(17,16): error CS0246: The type or namespace name 'DbSet&lt;&gt;' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\USER\source\repos\EventPlanner\EventPlanner\EventPlanner.csproj]
      Data\EventContext.cs(18,16): error CS0246: The type or namespace name 'DbSet&lt;&gt;' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\USER\source\repos\EventPlanner\EventPlanner\EventPlanner.csproj]
      Data\EventContext.cs(12,29): error CS0246: The type or namespace name 'DbContextOptions&lt;&gt;' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\USER\source\repos\EventPlanner\EventPlanner\EventPlanner.csproj]
          0 Warning(s)
          6 Error(s)
  
  </code></pre>
  <p>Would anyone have a suggestion as to why this might be happening? I am using version 5.0.6 of the NuGet package Microsoft.EntityFrameworkCore. I have tried uninstalling and reinstalling the package, and the red lines go away temporarily, but as soon as I run the migration command they're back again.</p>
  <p>Thanks,</p>
  <p>Robert</p>
  <p>London, UK</p>
  <p>//
  Context class:</p>
  <pre><code>
      using System;
      using System.Collections.Generic;
      using System.Linq;
      using System.Threading.Tasks;
      using Microsoft.EntityFrameworkCore;
      using EventPlanner.Models;
      
      namespace EventPlanner.Data
      {
          public class EventContext : DbContext
          {
              public EventContext(DbContextOptions&lt;EventContext&gt; options) : base(options)
              {
              }
      
              public DbSet&lt;Event&gt; Events { get; set; }
              public DbSet&lt;Band&gt; Bands { get; set; }
              public DbSet&lt;Caterer&gt; Caterers { get; set; }
          }
      }
  
  </code></pre>
  <p>// Startup.cs</p>
  <pre><code>
      public void ConfigureServices(IServiceCollection services)
              {
                  services.AddControllersWithViews();
      
                  services.AddDbContext&lt;EventContext&gt;(options =&gt;
                      options.UseSqlServer(Configuration.GetConnectionString(&quot;DefaultConnection&quot;)));
                  
              }
  
  </code></pre>