Entity Framework WebApi Circular dependency serialization error

KninyLata

New Member
I think, I've read everything about this error and I tried everything. Here are my models:Main:\[code\]public class Trip{ public int TripId { get; set; } public string Name { get; set; } public string ShortDescription { get; set; } public string Country { get; set; } public float BasicPrice { get; set; } public virtual ICollection<ApartmentType> ApartmentType { get; set; } public virtual ICollection<TransportMethod> TransportMethod { get; set; } public virtual ICollection<FeedingType> FeedingType { get; set; }}\[/code\]ApartmentType:\[code\]public class TransportMethod{ public int TransportMethodId { get; set; } public int TripId { get; set; } public string Name { get; set; } public float Price { get; set; }}\[/code\]FeedingType:\[code\]public class FeedingType{ public int FeedingTypeId { get; set; } public int TripId { get; set; } public string Description { get; set; } public float Price { get; set; }}\[/code\]TransportType:\[code\]public class TransportMethod{ public int TransportMethodId { get; set; } public int TripId { get; set; } public string Name { get; set; } public float Price { get; set; }}\[/code\]When serializng the Trip entity I get a circular dependency error. Things i tried:[*]Disable lazy loading in DbContext.[*]Adding json.SerializerSettings.PreserveReferencesHandling=Newtonsoft.Json.PreserveReferencesHandling.All; to GLobal.asax[*]Adding a decorator [IgnoreDataMember] to TripId in every child entity.[*]Mapping this entity to a ViewModel which doesn't contain the ICollection members. - This worked ok, but at some point I will want to get those lists to the client.I really don't know what's going on. What am I missing? I really can't spot any circular dependency.
 
Back
Top