我正在尝试在代码中使用Is Identity来提高TransactionId。但它显示以下错误:
SqlException:无法为身份列插入显式值 IDENTITY_INSERT设置为OFF时,表“ TransactionHistories”。
我尝试使用val payloadString = String(ndefRecord.payload, StandardCharsets.US_ASCII)
val payloadString = String(ndefRecord.payload, StandardCharsets.UTF_8)
语法。但这没有用。
[DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
public partial class TransactionHistories
{
[DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
public int TransactionId { get; set; }
public DateTime? TransactionDate { get; set; }
public long? CheckingAccountNumber { get; set; }
public long? SavingAccountNumber { get; set; }
[DisplayName("Transffered Amount")]
public decimal? Amount { get; set; }
public decimal? Transactionfee { get; set; }
public long? TransactionTypeId { get; set; }
}
以上是我的模型类,TransactionId是主键,这是我试图使用Is Identity将其增加1的值。我该如何进行这项工作?请给我任何建议和帮助。
答案 0 :(得分:-1)
Cannot insert explicit value for identity column in table 'table' when IDENTITY_INSERT is set to OFF
SET IDENTITY_INSERT“表”已打开