title: 'ApplicationDbContext' does not inherit from DbContext
body: <p>I´m getting this error:</p>
  <p>The type <code>ApplicationDbContext</code> does not inherit from <code>DbContext</code>. The <code>DbMigrationsConfiguration.ContextType</code> property must be set to a type that inherits from <code>DbContext</code>.</p>
  <p>This is my code:</p>
  <pre><code>using Microsoft.EntityFrameworkCore;
  using System;
  using System.Collections.Generic;
  //using System.Data.Entity;
  using System.Linq;
  using System.Threading.Tasks;
  
  namespace Manufactura.Models
  {
      public class ApplicationDbContext : DbContext
      {
          public ApplicationDbContext(DbContextOptions&lt;ApplicationDbContext&gt; options)
              : base(options)
          {
  
          }
  
          public DbSet&lt;Categories&gt; Categories { get; set; }
          public DbSet&lt;CustomerCities&gt; CustomerCities { get; set; }
          public DbSet&lt;CustomerCountries&gt; CustomerCountries { get; set; }
          public DbSet&lt;CustomerRegions&gt; CustomerRegions { get; set; }
          public DbSet&lt;Customers&gt; Customers { get; set; }
          public DbSet&lt;Employees&gt; Employees { get; set; }
          public DbSet&lt;Payments&gt; Payments { get; set; }
          public DbSet&lt;ProductDetails&gt; ProductDetails { get; set; }
          public DbSet&lt;ProductionOrders&gt; ProductionOrders { get; set; }
          public DbSet&lt;Products&gt; Products { get; set; }
          public DbSet&lt;RawMaterials&gt; RawMaterials { get; set; }
          public DbSet&lt;SaleInvoices&gt; SaleInvoices { get; set; }
          public DbSet&lt;Shippings&gt; Shippings { get; set; }
          public DbSet&lt;SuplierCities&gt; SuplierCities { get; set; }
          public DbSet&lt;SuplierCountries&gt; SuplierCountries { get; set; }
          public DbSet&lt;SuplierInvoices&gt; SuplierInvoices { get; set; }
          public DbSet&lt;SuplierRegions&gt; SuplierRegions { get; set; }
          public DbSet&lt;Supliers&gt; Supliers { get; set; }
          
  
          protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
          {
              // optionsBuilder.UseSqlServer(@&quot;Server=.\SQLEXPRESS;Database=SchoolDB;Trusted_Connection=True;&quot;);
  
          }
  
          protected override void OnModelCreating(ModelBuilder modelBuilder)
          {
              modelBuilder.Entity&lt;Categories&gt;().HasKey(m =&gt; m.CategoryId);
              modelBuilder.Entity&lt;CustomerCities&gt;().HasKey(m =&gt; m.CustomerCity);
              modelBuilder.Entity&lt;CustomerCountries&gt;().HasKey(m =&gt; m.CustomerCountry);
              modelBuilder.Entity&lt;CustomerRegions&gt;().HasKey(m =&gt; m.CustomerRegion);
              modelBuilder.Entity&lt;Customers&gt;().HasKey(m =&gt; m.CustomerId);
              modelBuilder.Entity&lt;Employees&gt;().HasKey(m =&gt; m.EmployeeId);
              modelBuilder.Entity&lt;Payments&gt;().HasKey(m =&gt; m.PaymentId);
              modelBuilder.Entity&lt;ProductDetails&gt;().HasKey(m =&gt; m.ProductDetailsId);
              modelBuilder.Entity&lt;ProductionOrders&gt;().HasKey(m =&gt; m.ProductionOrdersId);
              modelBuilder.Entity&lt;Products&gt;().HasKey(m =&gt; m.ProductId);
              modelBuilder.Entity&lt;RawMaterials&gt;().HasKey(m =&gt; m.RawMaterialsId);
              modelBuilder.Entity&lt;SaleInvoices&gt;().HasKey(m =&gt; m.SaleInvoiceId);
              modelBuilder.Entity&lt;Shippings&gt;().HasKey(m =&gt; m.ShippingId);
              modelBuilder.Entity&lt;SuplierCities&gt;().HasKey(m =&gt; m.SuplierCity);
              modelBuilder.Entity&lt;SuplierCountries&gt;().HasKey(m =&gt; m.SuplierCountry);
              modelBuilder.Entity&lt;SuplierInvoices&gt;().HasKey(m =&gt; m.SuplierInvoiceId);
              modelBuilder.Entity&lt;SuplierRegions&gt;().HasKey(m =&gt; m.SuplierRegion);
              modelBuilder.Entity&lt;Supliers&gt;().HasKey(m =&gt; m.SuplierId);
  
              modelBuilder.Entity&lt;Products&gt;()
              .HasOne(p =&gt; p.Category)
              .WithMany(b =&gt; b.Products);
  
              modelBuilder.Entity&lt;CustomerRegions&gt;()
             .HasOne(p =&gt; p.CustomerCountry)
             .WithMany(b =&gt; b.CustomerRegions);
  
              modelBuilder.Entity&lt;CustomerCities&gt;()
             .HasOne(p =&gt; p.CustomerRegion)
             .WithMany(b =&gt; b.CustomerCities);
  
              modelBuilder.Entity&lt;Customers&gt;()
             .HasOne(p =&gt; p.CustomerCity)
             .WithMany(b =&gt; b.Customers);
  
              modelBuilder.Entity&lt;SaleInvoices&gt;()
             .HasOne(p =&gt; p.Customer)
             .WithMany(b =&gt; b.SaleInvoices);
  
              modelBuilder.Entity&lt;Payments&gt;()
             .HasOne(p =&gt; p.SaleInvoice)
             .WithMany(b =&gt; b.Payments);
  
              modelBuilder.Entity&lt;ProductDetails&gt;()
             .HasOne(p =&gt; p.SaleInvoice)
             .WithMany(b =&gt; b.ProductDetails);
  
              modelBuilder.Entity&lt;Products&gt;()
             .HasOne(p =&gt; p.ProductDetail)
             .WithMany(b =&gt; b.Products);
  
              modelBuilder.Entity&lt;Products&gt;()
             .HasOne(p =&gt; p.ProductionOrder)
             .WithMany(b =&gt; b.Products);
  
              modelBuilder.Entity&lt;Products&gt;()
             .HasOne(p =&gt; p.Employee)
             .WithMany(b =&gt; b.Products);
  
              modelBuilder.Entity&lt;Products&gt;()
             .HasOne(p =&gt; p.Category)
             .WithMany(b =&gt; b.Products);
  
              modelBuilder.Entity&lt;ProductionOrders&gt;()
             .HasOne(p =&gt; p.RawMaterial)
             .WithMany(b =&gt; b.ProductionOrders);
  
              modelBuilder.Entity&lt;SuplierInvoices&gt;()
             .HasOne(p =&gt; p.RawMaterial)
             .WithMany(b =&gt; b.SuplierInvoices);
  
              modelBuilder.Entity&lt;SuplierInvoices&gt;()
             .HasOne(p =&gt; p.Suplier)
             .WithMany(b =&gt; b.SuplierInvoices);
  
              modelBuilder.Entity&lt;Supliers&gt;()
             .HasOne(p =&gt; p.SuplierCity)
             .WithMany(b =&gt; b.Supliers);
  
              modelBuilder.Entity&lt;SuplierCities&gt;()
             .HasOne(p =&gt; p.SuplierRegion)
             .WithMany(b =&gt; b.SuplierCities);
  
              modelBuilder.Entity&lt;SuplierRegions&gt;()
             .HasOne(p =&gt; p.SuplierCountry)
             .WithMany(b =&gt; b.SuplierRegions);
  
              base.OnModelCreating(modelBuilder);
          }
  
      }
  }
  </code></pre>
  <p>I´ve tried all that this site says, including restarting VS:</p>
  <pre><code>enable-migrations -ProjectName Manufactura -Verbose
  
  Enable-Migrations -ProjectName Manufactura -ContextTypeName Manufactura.Models.ApplicationDbContext
  
  Enable-Migrations -ProjectName Manufactura -ContextTypeName Manufactura.Models.ApplicationDbContext -force
  
  Install-Package EntityFramework -IncludePrerelease
  
  UnInstall-Package EntityFramework 
  
  Install-Package EntityFramework
  </code></pre>
  <p>This an application of <strong>.Net Core 3.1</strong> in <strong>VS 2019</strong></p>
  <p>If I uncomment <code>System.Data.Entity</code>, i get the error: <code>DbContext</code> is an ambiguous reference</p>
  <p>Nothing works.</p>
  <p>This is my appsettings</p>
  <pre><code>{
    &quot;ConnectionStrings&quot;: {
      &quot;ConnectionString&quot;: &quot;Data Source=.;Initial catalog=confecciones;Integrated Security=true&quot;
    },
  
    &quot;Logging&quot;: {
      &quot;LogLevel&quot;: {
        &quot;Default&quot;: &quot;Information&quot;,
        &quot;Microsoft&quot;: &quot;Warning&quot;,
        &quot;Microsoft.Hosting.Lifetime&quot;: &quot;Information&quot;
      }
    },
    &quot;AllowedHosts&quot;: &quot;*&quot;
  }
  </code></pre>
  <p>Usin f12 on DbContext, it take me here:</p>
  <pre><code>namespace Microsoft.EntityFrameworkCore
  ublic class DbContext : IDisposable, IAsyncDisposable, IInfrastructure&lt;IServiceProvider&gt;, IDbContextDependencies, IDbSetCache, IDbContextPoolable, IResettableService
      {
          //
          // Resumen:
          //     Initializes a new instance of the Microsoft.EntityFrameworkCore.DbContext class
          //     using the specified options. The Microsoft.EntityFrameworkCore.DbContext.OnConfiguring(Microsoft.EntityFrameworkCore.DbContextOptionsBuilder)
          //     method will still be called to allow further configuration of the options.
          //
          // Parámetros:
          //   options:
          //     The options for this context.
          public DbContext([NotNullAttribute] DbContextOptions options);
          //
          // Resumen:
          //     Initializes a new instance of the Microsoft.EntityFrameworkCore.DbContext class.
          //     The Microsoft.EntityFrameworkCore.DbContext.OnConfiguring(Microsoft.EntityFrameworkCore.DbContextOptionsBuilder)
          //     method will be called to configure the database (and other options) to be used
          //     for this context.
          protected DbContext();
  </code></pre>
  <p>Startup code:</p>
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  //using System.Data.Entity;
  using System.Threading.Tasks;
  using Microsoft.AspNetCore.Builder;
  using Microsoft.AspNetCore.Hosting;
  using Microsoft.AspNetCore.HttpsPolicy;
  using Microsoft.AspNetCore.Mvc;
  using Microsoft.Extensions.Configuration;
  using Microsoft.Extensions.DependencyInjection;
  using Microsoft.Extensions.Logging;
  using Microsoft.Extensions.Options;
  using Microsoft.EntityFrameworkCore;
  using Manufactura.Models;
  using Microsoft.Extensions.Hosting;
  
  namespace Manufactura
  {
      public class Startup
      {
          public Startup(IConfiguration configuration)
          {
              Configuration = configuration;
          }
  
          public IConfiguration Configuration { get; }
  
          // This method gets called by the runtime. Use this method to add services to the container.
          public void ConfigureServices(IServiceCollection services)
          {
              //services.AddRazorPages();
                          
              services.AddDbContext&lt;ApplicationDbContext&gt;(options =&gt; options.UseSqlServer(Configuration.GetConnectionString(&quot;ConnectionString&quot;)));
              services.AddControllers();
  
          }
  
          // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
          public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
          {
              if (env.IsDevelopment())
              {
                  app.UseDeveloperExceptionPage();
              }
              else
              {
                  app.UseExceptionHandler(&quot;/Error&quot;);
                  // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                  app.UseHsts();
              }
  
              app.UseHttpsRedirection();
              app.UseStaticFiles();
  
              app.UseRouting();
  
              app.UseAuthorization();
  
              app.UseEndpoints(endpoints =&gt;
              {
                  endpoints.MapRazorPages();
              });
          }
      }
  }
  </code></pre>
  <p>Appsettings:</p>
  <pre><code>{
  
  
    &quot;Logging&quot;: {
      &quot;LogLevel&quot;: {
        &quot;Default&quot;: &quot;Information&quot;,
        &quot;Microsoft&quot;: &quot;Warning&quot;,
        &quot;Microsoft.Hosting.Lifetime&quot;: &quot;Information&quot;
      }
    },
    &quot;AllowedHosts&quot;: &quot;*&quot;,
    &quot;ConnectionStrings&quot;: {
      &quot;ConnectionString&quot;: &quot;Data Source=DESKTOP-APHO8VE\\SQLEXPRESS;Initial catalog=confecciones;Integrated Security=true&quot;
    }
  }
  </code></pre>