I'm using Entity Framework 6.0 and Code First to migrate a legacy database schema to a new schema.
I'm getting an unexpected error upon querying EMPLOYEES
:
The entity set or function import 'EMPLOYEES' is not defined in the entity container 'WebModel'. Near escaped identifier, line 1, column 14.
Here's the relevant parts of the context class.
public partial class WebModel : DbContext
{
public WebModel : base("name=WebModel") { }
public virtual DbSet<LEGACY_EMPLOYEE> EMPLOYEES { get; set; }
public virtual DbSet<Employee> Employees { get; set; }
}
LEGACY_EMPLOYEE
is a class that was generated by the built-in POCO generator from the legacy schema, and Employee
is part of the new code first schema I've converting to.
In isolation, either one works. How do I fix this?
The public virtual DbSet<LEGACY_EMPLOYEE> EMPLOYEES { get; set; }
property can't have the same case insensitive name as another DbSet
.
To clear this up, rename it to something else, like public virtual DbSet<LEGACY_EMPLOYEE> LEGACY_EMPLOYEES { get; set; }