0

我有一个由以下字段组成的视图模型

public class ProfileViewModel
{

public String description { get; set; }
public Double height { get; set; }
public Double weight { get; set; }

public List<InterestDescription> interestedBy { get; set; }
}

InterestDescription是保存在我的数据库中的另一个实体。

我想让用户能够同时创建其个人资料并添加兴趣描述

我的问题是 InterestDescription 实体与 profile 有多对一的关系,所以我不能在没有创建 profile 的情况下创建 interestdescription。

我的问题是:是否可以绕过实体框架中特定插入的外键约束,如果不能,您能否建议我其他解决方法?

4

1 回答 1

0

不,你不能。

你不应该这样做。只要您一次保存更改,就应该以正确的顺序在数据库中创建实体。

于 2012-12-18T14:34:37.840 回答