注册

自增主键插入两条数据报错

李朋 2023/04/24 961 0

为提高效率,提问时请提供以下信息,问题描述清晰可优先响应。
【DM版本】:DM8(–03134283938-20221019-172201-20018)
【操作系统】:windows 10 64位
【CPU】:i5-10500
【问题描述】*:
执行带有自增主键id的两条数据插入,提示:The property 'Id' on entity type 'GatewayApiLog' has a temporary value while attempting to change the entity's state to 'Unchanged'. Either set a permanent value explicitly or ensure that the database is configured to generate values for this property
image.png
初步排查,可能是在一次SaveChange里面执行了两个表的插入有关。问题必现,可用我在社区链接中的demo代码进行验证
初步定位:可能和Clob字段的插入和sql语句过长有关,因为把clob的字段插入去掉或者把for循环里面改成3个就可以插入成功
demo代码见:自增主键插入报错demo.zip

回答 0
暂无回答
扫一扫
联系客服