参考证书中的依赖属性映射到存储生成的列。列:'ID' [英] A dependent property in a ReferentialConstraint is mapped to a store-generated column. Column: 'ID'

查看:100
本文介绍了参考证书中的依赖属性映射到存储生成的列。列:'ID'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道为什么当我尝试添加一个Venue对象并调用SaveChanges()时,我收到这个错误。与Venue对象的模型中唯一的区别是它与City的1到1..0关系。

  City city = ProcessCityCache (ev,country,db); //在这个电话之后,'city'已经持续了。 
场地=新地点{
TicketMasterURL = ev.VenueSeoLink,
Name = Capitalize(ev.VenueName),
City = city
};
db.Venues.AddObject(places);
db.SaveChanges(); //这里抛出异常。

任何见解将不胜感激!





(打开其中的图像自己的标签/窗口查看完整大小)

解决方案

我发现问题。是我的错。我将我的 FK_Venue_City 关系设置为 City.ID - > Venue.ID 我想要的是 City.ID - > Venue.CityID 。我在数据库中进行了更改,然后更新了模型。


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.

这篇关于参考证书中的依赖属性映射到存储生成的列。列:'ID'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆