ef core子表不能自定义id

Database operation expected to affect 1 row(s) but actually affected 0 row(s). Data may have been modified or deleted since entities were loaded

是如果子表主键,没有特殊说明,ef会默认认为这个字段数据库会自动生成,但是主表却可以

解决办法 配置子表//builder.Property(p => p.Id).ValueGeneratedNever(); 不自动生成id

posted @ 2021-06-22 16:36  菜洋  阅读(176)  评论(0编辑  收藏  举报