在 Visual Studio 上使用 Identity 创建新表和属性

Creating new tables and properties with Identity on Visual Studio

我正在尝试创建新的 tables 以及默认身份 tables 和我的之间的关系,但是当我尝试使用方法“SignInManager.PasswordSignInAsync”登录时默认情况下在 AccountController 上我得到下面列出的错误:

我为创建身份上下文所做的是检查项目启动时的选项,然后在 AspNetUser 上创建额外的属性 table 我这样做:

public class ApplicationUser : IdentityUser
{

    #region

    public DateTime LastLoginDateTime { get; set; }

    public string Name { get; set; }

    public string Surnames { get; set; }

    public string DNI { get; set; }

    public string ProfileImageSource { get; set; }

    #endregion


    public async Task<ClaimsIdentity> GenerateUserIdentityAsync(UserManager<ApplicationUser> manager)
    {
        // Tenga en cuenta que el valor de authenticationType debe coincidir con el definido en CookieAuthenticationOptions.AuthenticationType
        var userIdentity = await manager.CreateIdentityAsync(this, DefaultAuthenticationTypes.ApplicationCookie);
        // Agregar aquí notificaciones personalizadas de usuario
        return userIdentity;
    }
}

然后我使用 Enable-Migrations 和 Update-Database。

直到这里一切正常,但是当我使用同一解决方案中的另一个项目添加新的 table 和关系时(只是为了不混合我认为不好的上下文)与 entity framework 和然后更新数据库我遇到了上面提到的问题。

注册新用户时工作正常,但调用方法“SignInManager.PasswordSignInAsync”时程序崩溃。

我不知道我做错了什么猜猜有人可以帮助我。

我刚刚解决了这个问题。

我不知道为什么,但是如果我在 SQL 服务器中从 0 创建数据库而不是 Visual Studio EDMX 编辑器,它工作完美。

如果你想解决和我一样的问题,直接在SQL服务器上进行更改。