c# - Why is the return type IdentityUser and not ApplicationUser? -
i have class
public class applicationuser : identityuser { public string email { get; set; } public string confirmationtoken { get; set; } public bool isconfirmed { get; set; } ... } and in dbcontext class i've done
public partial class pickerdbcontext : identitydbcontext { public pickerdbcontext():base("defaultconnection") { } protected override void onmodelcreating(dbmodelbuilder modelbuilder) { base.onmodelcreating(modelbuilder); modelbuilder.entity<applicationuser>().totable("users"); modelbuilder.entity<identityuser>().totable("users"); modelbuilder.entity<identityrole>().totable("roles"); } //public dbset<license> licenses { get; set; } .... } now when try query users table in repository like
var user = _db.users.singleordefault(u=>u.anyfield); i think has return type identityuser , not applicationuser because when u=>u. intellisense option doesn't show fields applicationuser

what should make querying in users table return applicationuser type , why giving me return type identityuser
because identitydbcontext not class defined, , applicationuser class did define. create applicationuser inherits identityuser. create context inherits identitydbcontext. identitydbcontext exposes dbset.
if want data come applicationuser can following:
context.users.oftype<applicationuser>(); you may able in custom dbcontext (unverified):
public new dbset<applicationuser> users { get; set; } i haven't tested though.
Comments
Post a Comment