I can't figure out why I get this error when I try to add a Venue object and call SaveChanges(). The only difference in the model with Venue objects is they are 1 to 1..0 relation with City.
City city = ProcessCityCache(ev, country, db); // After this call, 'city' is already persisted.
venue = new Venue {
TicketMasterURL = ev.VenueSeoLink,
Name = Capitalize(ev.VenueName),
City = city
};
db.Venues.AddObject(venue);
db.SaveChanges(); // Exception thrown here.
Any insight would be greatly appreciated!
(Open the image in its own tab/window to see full size)
I found the problem. It was my fault. I had my FK_Venue_City
relationship set as City.ID
-> Venue.ID
where what I wanted was City.ID
-> Venue.CityID
. I made that change in my database then updated the model.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With