I used nuget to upgrade EF5 to EF6, and somewhere the change was changed for my solution. I discovered this when running one of my unit tests (this all affects everything). In each test, I initialize this:
using (var context = new ReportingDbContext())
{
context.Database.Initialize(false);
}
_inventoryService = new InventoryService();
This throws me this exception:
The property 'EmployeeID' cannot be configured as a navigation property. The property must be a valid entity type and the property should have a non-abstract getter and setter. For collection properties the type must implement ICollection<T> where T is a valid entity type.
The strange thing, everything was just a peach on EF5. I went hunting through my models (I have a bunch) and found wherever EmployeeID lives. They all look like this:
[Table("mytablename")]
public class CSATEntity
{
[Key, DatabaseGenerated(DatabaseGeneratedOption.None)]
public int CSATID { get; set; }
public int ClientID { get; set; }
public int ContactID { get; set; }
[ForeignKey("ClientID")]
public virtual CompanyEntity CompanyEntity { get; set; }
[ForeignKey("EmployeeID")]
public virtual EmployeeEntity EmployeeEntity { get; set; }
... more props
The exception does not take into account which model is hacked, or all of them. What is the best way to find this?
source
share