Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

A dependent property in a ReferentialConstraint is mapped to a store-generated column. Column: 'ID'

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!

Model Diagram

(Open the image in its own tab/window to see full size)

like image 858
Nick Strupat Avatar asked Jul 10 '11 17:07

Nick Strupat


1 Answers

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.

like image 104
Nick Strupat Avatar answered Oct 10 '22 12:10

Nick Strupat