I´m using code first, a database with about 60 tables, the error on the title occurs on 3 tables and i dont understand why...
int count_manual = db.Database.SqlQuery<int>("select count(*) from My_Table").Single(); // This works
int count = db.My_Table.Count(); // this throws an exception
The exception I´m getting is "The entity set or function import 'My_Table' is not defined in the entity container 'My_Context'"
This is my bdset
public DbSet<My_Table> My_Table { get; set; }
This is the only reference i have in the My_Context class fro My_Table (including case sensitive checks).
If i change the variable name to anything else, it works. Example:
public DbSet<My_Table> My_Table_1 { get; set; }
My model creating is overriden:
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
base.OnModelCreating(modelBuilder);
modelBuilder.Conventions.Remove<ManyToManyCascadeDeleteConvention>();
modelBuilder.Conventions.Remove<OneToManyCascadeDeleteConvention>();
}
I am unable to find anything wrong, does anyone has a clue what i might be missing?