How to add custom table in ASP.NET IDENTITY?(如何在 ASP.NET IDENTITY 中添加自定义表?)
问题描述
我在我的 Web 表单应用程序上使用 ASP.NET Identity.以下是我当前的身份表:
I'm using ASP.NET Identity on my web form application. Below is my current identity tables:
- Role
- User
- UserClaim
- UserLogin
- UserRole
我需要添加一个新表来存储其他信息.
I need to add a new table to store additional information.
新表中的字段:
- 用户登录 ID (PK)
- 用户 ID (FK)
- IP 地址
- 登录日期
如何添加这个自定义表格?我知道如何在现有表中添加自定义字段,但我不知道如何实现.
How can I add this custom table? I know how to add custom fields inside existing table but I don't know how to achieve this.
感谢您为解决我的问题所做的努力.
I appreciate your efforts in reaching a solution for my problem.
推荐答案
public class ApplicationUser : IdentityUser
{
public virtual ICollection<UserLog> UserLogs { get; set; }
}
public class UserLog
{
[Key]
public Guid UserLogID { get; set; }
public string IPAD { get; set; }
public DateTime LoginDate { get; set; }
public string UserId { get; set; }
[ForeignKey("UserId")]
public virtual ApplicationUser User { get; set; }
}
public System.Data.Entity.DbSet<UserLog> UserLog { get; set; }
这篇关于如何在 ASP.NET IDENTITY 中添加自定义表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在 ASP.NET IDENTITY 中添加自定义表?
基础教程推荐
- C# 9 新特性——record的相关总结 2023-04-03
- SonarQube C# 分析失败“不是指针的有效行偏移" 2022-01-01
- 如果条件可以为空 2022-01-01
- Mono https webrequest 失败并显示“身份验证或解密失败" 2022-01-01
- 重新排序 WPF TabControl 中的选项卡 2022-01-01
- 将数据集转换为列表 2022-01-01
- 从 C# 控制相机设备 2022-01-01
- 更新 Visual Studio 中的 DataSet 结构以匹配新的 SQL 数据库结构 2022-01-01
- 获取C#保存对话框的文件路径 2022-01-01
- 在 VB6 或经典 ASP 中使用 .NET 2022-01-01
