c# - Entity Framework not recognizing Custom Identity Properties -
i've set applicationuser type this:
public class businessaccount : identityuser { [required] [maxlength(100)] public string repfirstname { get; set; } [required] [maxlength(100)] public string replastname { get; set; } [required] public string title { get; set; } [required] public datetime joindate { get; set; } public async task<claimsidentity> generateuseridentityasync(usermanager<businessaccount> manager, string authenticationtype) { var useridentity = await manager.createidentityasync(this, authenticationtype); // add custom user claims here return useridentity; } } i have dbcontext:
public class alehubdbcontext :identitydbcontext<businessaccount> { public alehubdbcontext() : base("defaultconnection", throwifv1schema: false) { configuration.proxycreationenabled = false; configuration.lazyloadingenabled = false; } public static alehubdbcontext create() { return new alehubdbcontext(); } } both in same namespace. however, when run migration, none of above-defined custom properties appearing. system scaffolds plain-old identityuser style table structure boilerplate. it's if ef doesn't "see" businessaccount entity. there other connection causing problem? thanks.
versions:
id versions projectname -- -------- ----------- entityframework {6.1.3} alehub.api microsoft.aspnet.identity.core {2.2.1} alehub.api microsoft.aspnet.identity.entity... {2.2.1} alehub.api microsoft.aspnet.identity.owin {2.2.1} alehub.api microsoft.aspnet.webapi {5.2.3} alehub.api microsoft.aspnet.webapi.client {5.2.3} alehub.api microsoft.aspnet.webapi.core {5.2.3} alehub.api microsoft.aspnet.webapi.owin {5.2.3} alehub.api microsoft.aspnet.webapi.owinself... {5.2.3} alehub.api microsoft.aspnet.webapi.webhost {5.2.3} alehub.api microsoft.codedom.providers.dotn... {1.0.0} alehub.api microsoft.net.compilers {1.0.0} alehub.api microsoft.owin {3.0.1} alehub.api microsoft.owin.host.httplistener {2.0.2} alehub.api microsoft.owin.hosting {2.0.2} alehub.api microsoft.owin.security {3.0.1} alehub.api microsoft.owin.security.cookies {3.0.1} alehub.api microsoft.owin.security.oauth {3.0.1} alehub.api newtonsoft.json {6.0.4} alehub.api owin {1.0} alehub.api antlr {3.4.1.9004} initial migration.... no custom props in sight! public partial class initialcreate : dbmigration { public override void up() { createtable( "dbo.aspnetroles", c => new { id = c.string(nullable: false, maxlength: 128), name = c.string(nullable: false, maxlength: 256), }) .primarykey(t => t.id) .index(t => t.name, unique: true, name: "rolenameindex");
createtable( "dbo.aspnetuserroles", c => new { userid = c.string(nullable: false, maxlength: 128), roleid = c.string(nullable: false, maxlength: 128), }) .primarykey(t => new { t.userid, t.roleid }) .foreignkey("dbo.aspnetroles", t => t.roleid, cascadedelete: true) .foreignkey("dbo.aspnetusers", t => t.userid, cascadedelete: true) .index(t => t.userid) .index(t => t.roleid); createtable( "dbo.aspnetusers", c => new { id = c.string(nullable: false, maxlength: 128), email = c.string(maxlength: 256), emailconfirmed = c.boolean(nullable: false), passwordhash = c.string(), securitystamp = c.string(), phonenumber = c.string(), phonenumberconfirmed = c.boolean(nullable: false), twofactorenabled = c.boolean(nullable: false), lockoutenddateutc = c.datetime(), lockoutenabled = c.boolean(nullable: false), accessfailedcount = c.int(nullable: false), username = c.string(nullable: false, maxlength: 256), }) .primarykey(t => t.id) .index(t => t.username, unique: true, name: "usernameindex"); createtable( "dbo.aspnetuserclaims", c => new { id = c.int(nullable: false, identity: true), userid = c.string(nullable: false, maxlength: 128), claimtype = c.string(), claimvalue = c.string(), }) .primarykey(t => t.id) .foreignkey("dbo.aspnetusers", t => t.userid, cascadedelete: true) .index(t => t.userid); createtable( "dbo.aspnetuserlogins", c => new { loginprovider = c.string(nullable: false, maxlength: 128), providerkey = c.string(nullable: false, maxlength: 128), userid = c.string(nullable: false, maxlength: 128), }) .primarykey(t => new { t.loginprovider, t.providerkey, t.userid }) .foreignkey("dbo.aspnetusers", t => t.userid, cascadedelete: true) .index(t => t.userid); } public override void down() { dropforeignkey("dbo.aspnetuserroles", "userid", "dbo.aspnetusers"); dropforeignkey("dbo.aspnetuserlogins", "userid", "dbo.aspnetusers"); dropforeignkey("dbo.aspnetuserclaims", "userid", "dbo.aspnetusers"); dropforeignkey("dbo.aspnetuserroles", "roleid", "dbo.aspnetroles"); dropindex("dbo.aspnetuserlogins", new[] { "userid" }); dropindex("dbo.aspnetuserclaims", new[] { "userid" }); dropindex("dbo.aspnetusers", "usernameindex"); dropindex("dbo.aspnetuserroles", new[] { "roleid" }); dropindex("dbo.aspnetuserroles", new[] { "userid" }); dropindex("dbo.aspnetroles", "rolenameindex"); droptable("dbo.aspnetuserlogins"); droptable("dbo.aspnetuserclaims"); droptable("dbo.aspnetusers"); droptable("dbo.aspnetuserroles"); droptable("dbo.aspnetroles"); } } }
Comments
Post a Comment