将列添加到ASP.NET MVC项目中创建的身份表中? [英] Add column to created identity table in asp.net mvc project?

查看:55
本文介绍了将列添加到ASP.NET MVC项目中创建的身份表中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在MVC 5项目中使用Identity 2.0.

I use identity 2.0 in my MVC 5 project.

第一次在数据库中运行项目时,已创建了用于身份验证和授权的所有默认表:

First time when I run the project in my DB has been created all default tables for authentication and authorization:

在AspNetUsers表中,我需要创建一个名为LoyoutId的整数类型的附加列.

In AspNetUsers table I need to create additional column named LoyoutId of type integer.

我的问题是如何向创建的默认表中添加列?

My question is how can I add column to created default tables?

推荐答案

您可以通过向ApplicationUser类添加更多属性来为用户添加配置文件数据,请访问

You can add profile data for the user by adding more properties to your ApplicationUser class, please visit this to learn more.

在您的情况下:

public class ApplicationUser : IdentityUser
{
     public int LoyoutId { get; set; }
}

然后打开程序包管理器控制台"并执行以下命令:

Then open the Package Manager Console and execute following commands:

PM> Enable-migrations //You don't need this as you have already done it
PM> Add-migration Give_it_a_name //This will generate a database script file
PM> Update-database //Run script file against database.

现在,所有新属性都将变成AspNetUsers表.

Now, all the new properties will turn into AspNetUsers table.

这篇关于将列添加到ASP.NET MVC项目中创建的身份表中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆