Asp.net mvc 扩展ApplicationUser不传播到表架构

Asp.net mvc 扩展ApplicationUser不传播到表架构,asp.net-mvc,entity-framework-6,Asp.net Mvc,Entity Framework 6,我已经用FirstName和LastName扩展了ApplicationUser类,但是当我创建迁移和数据库时,新属性不会显示。有什么想法吗 MyApplicationUserclass: public class ApplicationUser : IdentityUser<int, ApplicationUserLogin, ApplicationUserRole, ApplicationUserClaim>, IUser<int> { //extend wi

我已经用FirstName和LastName扩展了ApplicationUser类,但是当我创建迁移和数据库时,新属性不会显示。有什么想法吗

My
ApplicationUser
class:

public class ApplicationUser : IdentityUser<int, ApplicationUserLogin, ApplicationUserRole, ApplicationUserClaim>, IUser<int>
{
    //extend with additional properties here
    public string FirstName;
    public string LastName;

    public string GetFullName()
    {
        return FirstName + " " + LastName;
    }

    public async Task<ClaimsIdentity> GenerateUserIdentityAsync(UserManager<ApplicationUser, int> manager)
    {
        var userIdentity = await manager.CreateIdentityAsync(this, DefaultAuthenticationTypes.ApplicationCookie);
        return userIdentity;
    }
}
这是我创建迁移时创建的(仅提供部分迁移代码):


将变量设置为属性:

public class ApplicationUser : IdentityUser<int, ApplicationUserLogin, ApplicationUserRole, ApplicationUserClaim>, IUser<int>
{
    //extend with additional properties here
    public string FirstName { get; set ;}
    public string LastName { get; set; }

    public string GetFullName()
    {
        return FirstName + " " + LastName;
    }

    public async Task<ClaimsIdentity> GenerateUserIdentityAsync(UserManager<ApplicationUser, int> manager)
    {
        var userIdentity = await manager.CreateIdentityAsync(this, DefaultAuthenticationTypes.ApplicationCookie);
        return userIdentity;
    }
}
公共类应用程序用户:IdentityUser,IUser
{
//在此扩展附加属性
公共字符串名{get;set;}
公共字符串LastName{get;set;}
公共字符串GetFullName()
{
返回FirstName+“”+LastName;
}
公共异步任务GenerateUserIdentityAsync(用户管理器)
{
var userIdentity=wait manager.CreateIdentityAsync(这是DefaultAuthenticationTypes.ApplicationOkie);
返回用户身份;
}
}

您是否在这些属性上尝试了[NotMapping]属性?它不会将它们映射到database@alexo但是我希望这些属性显示在数据库中以存储值。aaa,它们不会显示,我以为你需要这样的属性。您声明了变量,而不是属性。试着让它们成为属性,它应该是有用的。我完全错过了。我忘了添加访问者!谢谢你,阿列克索。如果你根据你的评论创建了一个答案,我会把它标记为答案!
        CreateTable(
            "dbo.Users",
            c => new
                {
                    Id = c.Int(nullable: false, identity: true),
                    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");
public class ApplicationUser : IdentityUser<int, ApplicationUserLogin, ApplicationUserRole, ApplicationUserClaim>, IUser<int>
{
    //extend with additional properties here
    public string FirstName { get; set ;}
    public string LastName { get; set; }

    public string GetFullName()
    {
        return FirstName + " " + LastName;
    }

    public async Task<ClaimsIdentity> GenerateUserIdentityAsync(UserManager<ApplicationUser, int> manager)
    {
        var userIdentity = await manager.CreateIdentityAsync(this, DefaultAuthenticationTypes.ApplicationCookie);
        return userIdentity;
    }
}