I have damn time to figure out how to add entities like this to my db.
public class ThingWithListings { public virtual ICollection<Listing> Listings; } public class Listing { public int Id; public virtual ListingData Data { get; set; }
I extract "ThingWithLIstings" from another source and write it to my db. The tricky part is that any number of Listings can report the same listing. So when I add or update ThingWithListings, I need to see if the DataData listing exists, and if so, just use it.
I am new to EF, so I used AddOrUpdate from a Vickers article here : Obviously, don't work on this script, and so I tried a day or so to figure out the right way to do this. I will spare you the whole story of my major unsuccessful attempts and hope that someone can just tell me the right way to do this.
source share