首页 文章

ASP.NET标识 - ApplicationUser和我的自定义模型/实体

提问于
浏览
0

所有,

我读过这篇文章:How AspNet Identity with my model其中ApplicationUser的additing属性为

public int AddressId { get; set; }

这是ApplicationUser上的新属性 .

但我想知道的是,如果我有 my own 的自定义实体,我希望它有一个与应用程序用户相关的属性:

public class Book
{
    public int Id { get; set; }
    public string Title { get; set; }

    public ApplicationUser CurrentlyBorrowedBy { get; set; }
}

要么

public class Book
{
    public int Id { get; set; }
    public string Title { get; set; }

    public Guid CurrentlyBorrowedBy { get; set; }
}

我可能想要这样做的原因是我可以调用像GetAllBooksBorrowedForUser(userid)这样的方法 .

如上所示,我是否将属性类型设置为 ApplicationUser

or

使用Guid,因为 ApplicationUser 上Id的数据类型是Guid

or

这是完全错误的做法吗?

欢迎所有建议 .

Note :这只是伪代码,因为在我深入研究项目之前,我只想了解这一点 .

谢谢

拉斯

2 回答

相关问题