gpt4 book ai didi

c# - ReferentialConstraint 中的依赖属性映射到存储生成的列

转载 作者:IT王子 更新时间:2023-10-29 03:36:33 27 4
gpt4 key购买 nike

写入数据库时​​出现此错误:

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

public bool PayForItem(int terminalId, double paymentAmount, 
eNums.MasterCategoryEnum mastercategoryEnum, int CategoryId, int CategoryItemId)
{

using (var dbEntities = new DatabaseAccess.Schema.EntityModel())
{
int pinnumber = 0;
long pinid = 1; //getPinId(terminalId,ref pinnumber) ;
var payment = new DatabaseAccess.Schema.Payment();
payment.CategoryId = CategoryId;
payment.ItemCategoryId = CategoryItemId;
payment.PaymentAmount = (decimal)paymentAmount;
payment.TerminalId = terminalId;
payment.PinId = pinid;

payment.HSBCResponseCode = "";
payment.DateActivated = DateTime.Now;
payment.PaymentString = "Payment";
payment.PromotionalOfferId = 1;
payment.PaymentStatusId = (int)eNums.PaymentStatus.Paid;

//payment.PaymentId = 1;

dbEntities.AddToPayments(payment);
dbEntities.SaveChanges();
}
return true;
}

架构是:

enter image description here

最佳答案

您是否可能在表之间定义了错误的列关系?

在我的例子中,我有不同的列,其中一列设置为自动数字。

关于c# - ReferentialConstraint 中的依赖属性映射到存储生成的列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6384659/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com