title: The entity type <Entity> is not part of the model for the current context
body: <p>I am developing a fairly basic C# application using Data First Entity Framework Model. All was going well until I added a fifth table to my database and updated my my model from the database. Up I am still able to add, remove update data in all other tables in my database but for some reason I keep running into this issue with the last table that I added to my database. I am using Entity Framework 6x </p>
  
  <p>From all the research that I have done, this seems like a fairly common issue that people run into and I have tried several suggestions including...</p>
  
  <ul>
  <li>Changing the connection string to ADO.NET connection string</li>
  <li>Removing the entity and updating my EDMX model from the database.</li>
  <li>Connecting the entity to the table in void OnModelCreating(DbModelBuilder modelBuilder) function of context.cs</li>
  <li>Matching the connection strings in APP.config and Web.config.</li>
  </ul>
  
  <p>Nothing seems to have worked so far.</p>
  
  <pre><code>//Monies.Context.cs
  namespace MoneyManager.DB
  {
      using System;
      using System.Data.Entity;
      using System.Data.Entity.Infrastructure;
  
      public partial class MoniesEntities : DbContext
      {
          public MoniesEntities()
              : base("name=MoniesEntities")
          {
          }
  
          protected override void OnModelCreating(DbModelBuilder modelBuilder)
          {
              throw new UnintentionalCodeFirstException();
          }
  
          public virtual DbSet&lt;Country&gt; Countries { get; set; }
          public virtual DbSet&lt;Vendor&gt; Vendors { get; set; }
          public virtual DbSet&lt;Category&gt; Categories { get; set; }
          public virtual DbSet&lt;SubCategory&gt; SubCategories { get; set; }
          public virtual DbSet&lt;User&gt; Users { get; set; }
          public virtual DbSet&lt;Expense&gt; Expenses { get; set; }
      }
  }
  //Expense.cs
  namespace MoneyManager.DB
  {
      using System;
      using System.Collections.Generic;
  
      public partial class Expense
      {
          public System.Guid ExpenseId { get; set; }
          public System.Guid VendorId { get; set; }
          public System.Guid UserId { get; set; }
          public System.Guid CategoryId { get; set; }
          public System.Guid SubCategoryId { get; set; }
          public MoneyManager.DTO.Enums.PaymentMode PaymentMode { get; set; }
          public int PaymentMethod { get; set; }
          public string PaymentDetail { get; set; }
          public string Comment { get; set; }
          public decimal Amount { get; set; }
          public System.DateTime ExpenseDate { get; set; }
      }
  }
  
  //ExpenseRepository.cs
  namespace MoneyManager.DB
  {
      public class ExpenseRepository
      {
  
          public static void SaveExpense(DTO.Expense dtoExpense)
          {
              MoniesEntities db = new MoniesEntities();
  
              MoneyManager.DB.Expense expense = new MoneyManager.DB.Expense();
  
              expense.Amount = dtoExpense.Amount;
              expense.CategoryId = dtoExpense.CategoryId;
              expense.Comment = dtoExpense.Comment;
              expense.ExpenseDate = dtoExpense.ExpenseDate;
              expense.ExpenseId = dtoExpense.ExpenseId;
              expense.PaymentDetail = dtoExpense.PaymentDetail;
              expense.PaymentMethod = dtoExpense.PaymentMethod;
              expense.PaymentMode = dtoExpense.PaymentMode;
              expense.SubCategoryId = dtoExpense.SubCategoryId;
              expense.UserId = dtoExpense.UserId;
              expense.VendorId = dtoExpense.VendorId;
  
  
              db.Expenses.Add(expense);  //This is where I get this error
              db.SaveChanges();
          }
      }
  }
  </code></pre>
  
  <p>//Connection String
  </p>
  
  <p>
  </p>
  
  <p>Here is the stack trace</p>
  
  <blockquote>
    <p>InvalidOperationException: The entity type Expense is not part of the
    model for the current context.<br>
    System.Data.Entity.Internal.InternalContext.UpdateEntitySetMappingsForType(Type
    entityType) +209<br>
    System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type
    entityType) +51<br>
    System.Data.Entity.Internal.Linq.InternalSet<code>1.Initialize() +137<br>
    System.Data.Entity.Internal.Linq.InternalSet</code>1.get_InternalContext()
    +38    System.Data.Entity.Internal.Linq.InternalSet<code>1.ActOnSet(Action action, EntityState newState, Object entity, String methodName) +236<br>
    System.Data.Entity.Internal.Linq.InternalSet</code>1.Add(Object entity) +200
    System.Data.Entity.DbSet`1.Add(TEntity entity) +130<br>
    MoneyManager.DB.ExpenseRepository.SaveExpense(Expense dtoExpense) in
    c:\MoneyManager\MoneyManager.DB\ExpenseRepository.cs:31<br>
    MoneyManager.Domain.ExpenseManager.SaveExpense(Expense dtoExpense) in
    c:\MoneyManager\MoneyManager.Domain\ExpenseManager.cs:13 c:\
    MoneyManager.Web.ExpenseNew.submitButton_Click(Object sender,
    EventArgs e) in MoneyManager\MoneyManager.Web\ExpenseNew.aspx.cs:93<br>
    System.Web.UI.WebControls.Button.OnClick(EventArgs e) +9782698</p>
  </blockquote>