我只是在流浪,我想将我的数据插入关系数据中,但我试图不插入该模型的相关模型中。结果为null,并且在db中没有保存密钥。
一对一关系
C#ef核心
我在json中尝试过
{
testingName: "123231",
testingRelatedData: {
testingNameRelated: "asdasd"
}
}
和代码是在上下文中添加的一种正常方法。
class model {
public int modelid {get; set;}
public string testingName {get; set;}
public virtual testingNameRelated testingNameRelated { get; set; }
}
class testingNameRelated{
public int id {get; set;}
public string testingNameRelated{get; set;}
public model model {get; set;}
public int modelid {get; set;}
}
context.testing.add(model)
谢谢