I have a LINQ query that works in an EF 6 (Code First) project. Now I moved the code to EF 7, and this request now throws an exception: ArgumentException: the property 'Int32 ID' is not defined for type 'X.Models.Domain.MadeChoice'
Request:
var madeChoices = from res in X.Instance.Residence join room in X.Instance.Room on res.ID equals room.Residence.ID join madeChoice in X.Instance.MadeChoice on room.ID equals madeChoice.Room.ID where res.ID == residence.ID select room.MadeChoices;
MadeChoice Class:
public class MadeChoice { public virtual int ID { get; set; } [Required] public virtual ChoiceGroup Choicegroup { get; set; } [Required] public virtual Room Room { get; set; } [Required] public virtual Item Item { get; set; } }
Room Class:
public class Room { public virtual int ID { get; set; } public string Name { get; set; } public string Description { get; set; } public virtual Residence Residence { get; set; } public virtual RoomType RoomType { get; set; } public virtual List<MadeChoice> MadeChoices { get; set; }
Class of residence:
public class Residence { public int ID { get; set; } public string ApartmentNumber { get; set; } public static IQueryable<List<MadeChoice>> GetMadeChoices(Residence residence) { var madeChoices = from res in X.Instance.Residence join room in X.Instance.Room on res.ID equals room.Residence.ID join madeChoice in X.Instance.MadeChoice on room.ID equals madeChoice.Room.ID where res.ID == residence.ID select room.MadeChoices; System.Diagnostics.Debug.Write("MadeChoices.Count: "); System.Diagnostics.Debug.WriteLine(madeChoices.Count()); foreach (var madechoice in madeChoices) { System.Diagnostics.Debug.Write("MadeChoice.Count: "); System.Diagnostics.Debug.WriteLine(madechoice.Count()); } return madeChoices; }
Initially, the identifier was not virtual, but it did not affect the error. The database looks the same as in EF 6. This relationship is a one-to-many relationship. I am using EF 7.0.0-rc1-final.
Any clues?
Thanks in advance,
Peter
source share