Entity Framework Core导航属性加载问题
前言
今天下午在开发的时候发现EF Core实体模型中的导航属性为 null,经排查既不是没有加 virtual 关键字,也不是外键关系映射错误。

解决方法
通过查询官网文档,发现,原因在于EF Core目前不支持延迟加载,所以每次查询,都会得到 null 的导航属性。目前只有使用 预先加载 或 显示加载 才能得到正确的导航属性。
最后我使用显示加载成功得到导航属性的数据,具体使用方法可进官网文档查看。

Entity Framework Core导航属性加载问题的更多相关文章
- Entity Framework Core 导航属性 加载数据
Loading Related Data https://docs.microsoft.com/en-us/ef/core/querying/related-data Eager loading me ...
- 浅谈Entity Framework中的数据加载方式
如果你还没有接触过或者根本不了解什么是Entity Framework,那么请看这里http://www.entityframeworktutorial.net/EntityFramework-Arc ...
- Entity Framework 4.1 : 贪婪加载和延迟加载
这篇文章将讨论查询结果的加载控制. EF4.1 允许控制对象之间的关系,当我们进行查询的时候,哪些关系的数据将会被加载到内存呢?所有相关的对象都需要吗?在一些场合可能有意义,例如,当查询的实体仅仅拥有 ...
- 关闭Entity Framework的导航属性
public RIS30Entities() : base("name=RIS30Entities") { this.Configuration.ProxyCreationEnab ...
- Entity Framework Core 1.1 Preview 1 简介
实体框架核心(EF Core)是Entity Framework的一个轻量级,可扩展和跨平台版本. 10月25日,Entity Framework Core 1.1 Preview 1发布了. 升级到 ...
- Working with Data » Getting started with ASP.NET Core and Entity Framework Core using Visual Studio » 读取关系数据
Reading related data¶ 9 of 9 people found this helpful The Contoso University sample web application ...
- Entity Framework Core 1.1 升级通告
原文地址:https://blogs.msdn.microsoft.com/dotnet/2016/11/16/announcing-entity-framework-core-1-1/ 翻译:杨晓东 ...
- Working with Data » Getting started with ASP.NET Core and Entity Framework Core using Visual Studio » 更新关系数据
Updating related data¶ 7 of 7 people found this helpful The Contoso University sample web applicatio ...
- Working with Data » Getting started with ASP.NET Core and Entity Framework Core using Visual Studio » 创建复杂数据模型
Creating a complex data model 创建复杂数据模型 8 of 9 people found this helpful The Contoso University sampl ...
随机推荐
- over(partition by)开窗函数的使用
开窗函数是分析函数中的一种,开窗函数与聚合函数的区别是:开窗函数是用于计算基于组的某种聚合值且每个的组的聚合计算结果可以有多行,而聚合函数每个组的聚合计算结果只有一个.使用开窗函数可以在没有group ...
- Linux服务器---流量监控MRTG
MRTG MRTG可以分析网络流量,但是它必须依赖SNMP协议.将收集到的数据生成HTML文件,以图片的形式展示出来 1.安装一些依赖软件 [root@localhost bandwidthd-2.0 ...
- Javascript创建类的七种方法
/* 第一种定义类的方法 */var cls = new Object();cls.name = "wyf";cls.showName = function(){console.l ...
- STM32L476应用开发之六:电池SOC检测(转)
源: STM32L476应用开发之六:电池SOC检测
- 今日总结(linux和plsql)
#case ...when语句(根据字段不同值显示不同结果) ##1)case ...when语句的使用方法一: 语法格式: case column_name when value1 then res ...
- MySQL&MyBatis 时间处理的配合
1:Mysql 时间类型 mysql数据库:时间类型 1)datetime datetime: "yyyy-mm-dd hh:mm:ss" datetime "1000- ...
- JavaScript 条件判断算法综合实战
在赌场21点游戏中,玩家可以通过计算牌桌上已经发放的卡牌的高低值来让自己在游戏中保持优势,这就叫21点算法. 根据下面的表格,每张卡牌都分配了一个值.如果卡牌的值大于0,那么玩家应该追加赌注.反之,追 ...
- Could not get lock /var/lib/dpkg/lock - open (11: Resource temporarily unavailable) E: Unable to lock the administration di
alexander@alexander-virtual-machine:~$ sudo apt-get install -y httpdE: Could not get lock /var/lib/d ...
- mysql不常用但很有用的语句整理
mysqld_multi多实例停止.启动 mysqld_multi --defaults-file=/etc/my.cnf start 1,2 mysqld_multi --defaults-file ...
- 人机猜拳游戏Java
作业要求: 我的代码: package day20181119;/** * 猜拳游戏 * @author Administrator * @version1.0 */import java.util. ...