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 中添加自定义表?
基础教程推荐
- .NET SerialPort DataReceived 事件未触发 2022-01-01
- 我应该在后面的代码中直接使用 Linq To SQL 还是使 2022-01-01
- 禁止输入少量字符,例如'<'、'&a 2022-01-01
- C# 从 List<List<int>> 中删除重 2022-01-01
- 当值可以是对象或空数组时反序列化 JSON 2022-01-01
- Azure Functions:CosmosDBTrigger 未在 Visual Studio 中触发 2022-01-01
- WPF 模态进度窗口 2022-01-01
- Moq It.Is<>不匹配 2022-01-01
- 如果有人提交恶意软件Nuget包怎么办? 2022-01-01
- 如何使用 .Net 检查 Active Directory 服务器是否已启动并正在运行? 2022-01-01
