asp.net-web-api - 如果相关数据在插入时为空,则询问是否可以在相关数据中插入主键
问题描述
我只是在徘徊,我将我的数据插入到我试图不插入该模型的相关模型中的关系数据中。结果为空,并且在 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)
谢谢
解决方案
推荐阅读
- python-3.x - 并行化更新 pandas 列的过程
- javascript - SyntaxError: Unexpected identifier in C:\Users\Ak\Desktop\todolist-v1\views\list.ejs 同时编译 ejs
- json - TypeScript:如何为 json 对象建模
- laravel - Laravel 找出不同的队列
- java - 如何在 foreach 循环中增加计数
- python-3.x - ul标签中的所有li都使用beautifulSoup
- python - 如何从带有硒的A标签中获取文本?
- python-3.x - 我无法打印 Pandas DataFrame
- java - android.widget.Toolbar 无法转换为 androidx.appcompat.widget.Toolbar
- javascript - Javascript 中的用户定义对象