我需要准备成员的现有tbl_users表的MVC 5应用程序。我可以使用或修改ASP.Identity还是需要准备自定义会员资格?请建议。
CREATE TABLE [dbo].[tbl_user](
[id] [bigint] IDENTITY(1,1) NOT NULL,
[user] [varchar](50) NOT NULL,
[password] [varchar](60) NOT NULL,
[password_raw] [varchar](255) NULL,
[name] [varchar](255) NOT NULL,
[email] [varchar](255) NOT NULL,
[url] [varchar](255) NULL,
[language] [varchar](255) NULL,
[active] [smallint] NOT NULL,
[session_id] [varchar](100) NULL,
[reg_date] [datetime2](0) NOT NULL,
[theme] [varchar](255) NULL,
[timezone] [varchar](255) NULL,
[last_visit_date] [datetime2](0) NULL,
[past_visit_date] [datetime2](0) NULL,
[activation] [varchar](32) NULL,
[activation_date] [datetime2](0) NULL,
[ip_address] [varchar](255) NULL,
[security_question] [varchar](255) NULL,
[security_answer] [varchar](255) NULL,
[lock_url] [varchar](500) NULL,
[lock_is_locked] [smallint] NOT NULL,
[lock_time] [datetime2](0) NULL,
[change_password] [smallint] NOT NULL,
[last_change_password_date] [datetime2](0) NOT NULL,
[expire_date] [date] NULL,
[employee_no] [bigint] NULL,
[student_no] [bigint] NULL,
[parent_no] [bigint] NULL,
[user_type] [varchar](5) NULL,
[last_site] [varchar](50) NULL
谢谢。
您可以从iuser得出自定义用户类,并在那里定义属性(Extras)。这样的东西:
public class IdentityUser: IUser
{
#region Constructors
/// <summary>
/// Initializes a new instance of the <see cref="IdentityUser"/> class
/// </summary>
public IdentityUser()
{
Id = Guid.NewGuid().ToString();
Roles = (ICollection<IdentityUserRole>)new List<IdentityUserRole>();
}
/// <summary>
/// Initializes a new instance of the <see cref="IdentityUser"/> class
/// </summary>
/// <param name="username">Username for the user</param>
public IdentityUser(string username): this()
{
UserName = username;
}
#endregion
#region IUser<string> members
// Custom properties...
#endregion
}
您可以在此处找到更多信息:https://jinishbhardwaj.wordpress.com/2014/07/16/decoupling-asp-net-asp-net-sideity-2-0-2-0-from-entity-from-entity-frame-framework-in-mvc5-part-part-part-part-part-part-part-part-1/