【发布时间】:2015-01-29 12:04:14
【问题描述】:
我有两张桌子:user 和 userprofile
User 有一个列 id 这是一个 identity 并且是主键
Userprofile 有 userId 列,它是 user.id 的外键。
context.User.Add(userModel);
context.UserProfile.Add(userprofileMode);
context.SaveChanges();
但是当我执行user.id = userprofile.Userid 时,它不会保存值,因为它是标识列。 Entity Framework中如何将user表id的值保存到userprofile表的userid中?
【问题讨论】:
-
你能发布你的模型吗?
标签: asp.net-mvc entity-framework