title: How to solve migration problem in ASP.NET Core MVC app?
body: <p>I am learning to create web applications. First of all, I went through the tutorial on creating a web application with Movies on the Microsoft site, and everything worked out. But when I started to create an application in my own subject area, I ran into a migration problem. The problem is that as a result of the migration, I get an error, that I do not have a definition for the 'Movie'.</p>
  <blockquote>
  <p>Error CS1061: 'AlbumContext' does not contain a definition for 'Movie' and no accessible extension method 'Movie' accepting a first argument of type 'AlbumContext' could be found (are you missing a using directive or an assembly reference?)</p>
  </blockquote>
  <p>It should be added that I get the database connection string automatically as a result of scaffolding.</p>
  <p>There is my Model:</p>
  <pre><code>public class Album
  {
      public int Id { get; set; }
      public string Title { get; set; }
  
      [DataType(DataType.Date)]
      public DateTime ReleaseDate { get; set; }
      public string Genre { get; set; }
      public decimal Price { get; set; }
  
  }
  </code></pre>
  <p>Generated controller. There is nothing special, just simple CRUD methods. But first it was created, there was wrong return statements in Index method:</p>
  <pre><code>public async Task&lt;IActionResult&gt; Index()
      {
            return _context.Movie != null ? 
                        View(await _context.Movie.ToListAsync()) :
                        Problem(&quot;Entity set 'MvcAlbumeContext.Album'  is null.&quot;);
      }
  </code></pre>
  <p>Instead of this:</p>
  <pre><code>public async Task&lt;IActionResult&gt; Index()
      {
            return _context.Album != null ? 
                        View(await _context.Album.ToListAsync()) :
                        Problem(&quot;Entity set 'MvcAlbumeContext.Album'  is null.&quot;);
      }
  </code></pre>
  <p>Simple context:</p>
  <pre><code>public class MvcAlbumeContext : DbContext
  {
      public MvcAlbumeContext (DbContextOptions&lt;MvcAlbumeContext&gt; options)
          : base(options)
      {
      }
  
      public DbSet&lt;MvcAlbum.Models.Album&gt;? Album { get; set; }
  }
  </code></pre>
  <p>And connection string from appsettings:</p>
  <pre><code>&quot;ConnectionStrings&quot;: {
  &quot;MvcAlbumeContext&quot;: &quot;Data Source=MvcAlbumeContext-b15b56a9-dd3b-4d6a-870d-0c0872252605.db&quot;
  </code></pre>
  <p>}</p>