title: The entity type was not found. Ensure that the entity type has been added to the model
body: <p>I'm new to ASP.NET Core and i'm trying to insert an entity into an Entity Framework Core model scaffolded from a simple existing MariaDB database.</p>
  <p>This is the entity model:</p>
  <pre><code>    public class ScrapeAsincroni
      {
          public int Id { get; set; }
          public string Paese { get; set; }
          public string Engine { get; set; }
          public string Keywords { get; set; }
      }
  </code></pre>
  <p>This is the controller action that is supposed to add the entity:</p>
  <pre><code>    public JsonResult create(string paese, string engine, string keywords)
          {
              ScrapeAsincroni scrapeAsincrono = new ScrapeAsincroni {
                  Paese = paese,
                  Engine = engine,
                  Keywords = keywords
              };
              _context.Add(scrapeAsincrono);
  
              try
              {
                  _context.SaveChangesAsync();
              }
              catch (Exception ex)
              {
                  return Json(new Dictionary&lt;string, int?&gt; { { &quot;id&quot;, null } });
              }
              return Json(new Dictionary&lt;string, int?&gt;{ {&quot;id&quot;, scrapeAsincrono.Id} });
          }
  </code></pre>
  <p>The database context (_context) has been initialized on the controller's constructor.
  the line</p>
  <pre><code> _context.Add(scrapeAsincrono);
  </code></pre>
  <p>throws the following exception:</p>
  <blockquote>
  <p>System.InvalidOperationException: The entity type 'ScrapeAsincroni' was not found. Ensure that the entity type has been added to the model.</p>
  </blockquote>
  <p>This is the modelBuilder code relative to this model</p>
  <pre><code>   public partial class ScraperDbContext : DbContext
      {
          public ScraperDbContext()
          {
          }
  
          public ScraperDbContext(DbContextOptions&lt;ScraperDbContext&gt; options)
              : base(options)
          {
          }
  
          public virtual DbSet&lt;ScrapeAsincroni&gt; ScrapeAsincroni { get; set; }
  
          protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
          {
              if (!optionsBuilder.IsConfigured)
              {
                  #warning To protect potentially sensitive information in your connection string, you should move it out of source code. See http://go.microsoft.com/fwlink/?LinkId=723263 for guidance on storing connection strings.
                  optionsBuilder.UseMySql(&quot;server=#.#.#.#;port=####;user=####;password=####;database=####&quot;, x =&gt; x.ServerVersion(&quot;10.3.25-mariadb&quot;));
              }
          }
  
          protected override void OnModelCreating(ModelBuilder modelBuilder)
          {
              modelBuilder.Entity&lt;ScrapeAsincroni&gt;(entity =&gt;
              {
                  entity.HasComment(&quot;Informazioni su una ricerca asincrona dello Scraper&quot;);
  
                  entity.Property(e =&gt; e.Id)
                      .HasColumnName(&quot;id&quot;)
                      .HasColumnType(&quot;int(11)&quot;);
  
                  entity.Property(e =&gt; e.Engine)
                      .HasColumnName(&quot;engine&quot;)
                      .HasColumnType(&quot;varchar(255)&quot;)
                      .HasCharSet(&quot;utf8&quot;)
                      .HasCollation(&quot;utf8_general_ci&quot;);
  
                  entity.Property(e =&gt; e.Keywords)
                      .IsRequired()
                      .HasColumnName(&quot;keywords&quot;)
                      .HasColumnType(&quot;text&quot;)
                      .HasCharSet(&quot;utf8&quot;)
                      .HasCollation(&quot;utf8_general_ci&quot;);
  
                  entity.Property(e =&gt; e.Paese)
                      .HasColumnName(&quot;paese&quot;)
                      .HasColumnType(&quot;varchar(255)&quot;)
                      .HasCharSet(&quot;utf8&quot;)
                      .HasCollation(&quot;utf8_general_ci&quot;);
              });
  
              OnModelCreatingPartial(modelBuilder);
          }
  
          partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
      }         
  </code></pre>
  <p>I can't seem to understand why this happens, and couldn't find any solutions online.</p>