I modeled my m:m tables following the advice here code first many to many. Below is my model (and this is reflected in the database):
public class Catalog {
...
public virtual ICollection <CatalogItem> CatalogItems {get;set;}
public virtual ICollection <CatalogSubscriber> CatalogSubscribers {get;set;}
}
public class Item {
...
public virtual ICollection <CatalogItem> CatalogItems {get;set;}
}
public class Subscriber {
...
public virtual ICollection <CatalogSubscriber> CatalogSubscribers {get;set;}
}
public class CatalogItem{
[ForeignKey("Catalog")]
public Guid Catalog_Id { get; set; }
[ForeignKey("Item")]
public Guid Item_Id { get; set; }
public virtual Catalog Catalog { get; set; }
public virtual Item Item { get; set; }
}
public class CatalogSubscriber{
//similar to catalogitem
}
I am getting the error "invalid column Subscriber_Id" when trying to get catalogs, and I can see in the select statement that for some reason it thinks that Subscriber_Id is a column in Catalog (it isn't). I tried this solution, but to no avail. Funny thing is that CatalogItems were working perfectly, till I added the m:m on CatalogSubscribers. It doesn't seem to have a problem with CatalogItems at all. What am I doing wrong here?