我正在建立一个应用程序,使用ASP.Net MVC 5框架和数据库代码方法。 我需要添加自定义字段到我的用户表。添加自定义属性并稍后访问它们的最佳方式是什么? 以下是我迄今所做如何使用ASP.NET MVC 5框架将自定义属性添加到我的用户模型中?
- 登录到SQL Server和添加列到
AspNetUsers
表。 我创建了一个新类,其中
ApplicationUser
类似于我的User
类。public class User : ApplicationUser { public int UserId { get; set; } public int CampId { get; set; } }
此外,我尝试添加我的自定义属性为ApplicationUser
一样,直接在another question答案找到了insstruction,但我得到以下错误
The model backing the 'ApplicationDbContext' context has changed since the database was created. Consider using Code First Migrations to update the database (http://go.microsoft.com/fwlink/?LinkId=238269).
什么是最好的方式将列添加到我的AspNetUsers
表中?
另外,如何使用授权用户从控制器访问这些字段?
我知道不再支持数据库第一种方法 – ArgeKumandan