在ReferentialConstraint从属属性映射到存储生成列。专栏:“ID”属性、专栏、ReferentialConstraint、ID

由网友(浅夏殇琉璃)分享简介:我不明白,为什么我得到这个错误,当我尝试添加一个场地对象并调用调用SaveChanges()。与场馆对象模型的唯一区别是它们是1〜1..0关系与城市。I can't figure out why I get this error when I try to add a Venue object and call Sa...

我不明白,为什么我得到这个错误,当我尝试添加一个场地对象并调用调用SaveChanges()。与场馆对象模型的唯一区别是它们是1〜1..0关系与城市。

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.

任何有识之士将大大AP preciated!

Any insight would be greatly appreciated!

(开在自己的标签/窗口的图像看原图)

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

推荐答案

我发现这个问题。是我的错。我有我的 FK_Venue_City 关系设置为 City.ID - > Venue.ID 在这里我想要的是 City.ID - > Venue.CityID 。我做了我的数据库中的变化,然后更新模型。

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.

阅读全文

相关推荐

最新文章