【发布时间】:2015-09-28 00:12:12
【问题描述】:
如何在EF7 中指定我希望显式加载我的 ApplicationUser 实体的引用属性 Subject?在 EF6 中,在命名空间 System.Data.EntityFramework.Infrastructure 中定义了以下内容:
public DbReferenceEntry<TEntity, TProperty> Reference<TProperty>(Expression<Func<TEntity, TProperty>> navigationProperty) where TProperty : class;
所以这段代码:
public async override Task<ApplicationUser> FindByIdAsync(string userId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
{
var user = await base.FindByIdAsync(userId);
this.Context.Entry(user).Reference(u => u.Subjects).Load();
return user;
}
给出一个例外
EntityEntry<ApplicationUser> does not contain a definition for 'Reference'.
EF7 中定义的这个扩展方法在哪里?
【问题讨论】:
标签: asp.net-core entity-framework-core