I am trying to implement a custom UserStore
in Asp .Net 5 beta 7
based on the idea presented over here.
Here is the code for my custom user store:
public class ApplicationUserStore : UserStore<ApplicationUser>
{
public ApplicationUserStore(DbContext context)
: base(context)
{
}
public async override Task<ApplicationUser> FindByIdAsync(string userId)
{
var user = await base.FindByIdAsync(userId);
this.Context.Entry(user).Reference(u => u.Subject).Load();
return user;
}
}
I am encountering two issues with this code.
- No method FindByIdAsync to override in the base class
- Inside FindByIdAsync, the method Reference is not found
I am also not sure how I would go about configuring the custom user store once I get it to compile.
UPDATE:
The first issue I have solved by changing the definition of the FindByIdAsync override to the following:
public async override Task<ApplicationUser> FindByIdAsync(string userId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
The second issue is still a problem. How do I specify in EF7
that I wish to explicitly load the reference property Subject
of my ApplicationUser
entity? In EF6
the following is defined in the namespace System.Data.EntityFramework.Infrastructure:
public DbReferenceEntry<TEntity, TProperty> Reference<TProperty>(Expression<Func<TEntity, TProperty>> navigationProperty) where TProperty : class;
Where is this extension method defined in EF7
? Or is there a new method for explicitly loading references?