【发布时间】:2014-03-10 06:33:56
【问题描述】:
全部,
我读过这篇文章: How AspNet Identity with my model 其中 ApplicationUser 的添加属性为
public int AddressId { get; set; }
这是 ApplicationUser 上的一个新属性。
但我想知道的是,如果我有一个 我自己的 自定义实体并且我希望它具有与应用程序用户相关的属性:
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,如上所示
或
使用 Guid,因为 ApplicationUser 上的 Id 的 DataType 是 Guid
或
这是完全错误的做法吗?
欢迎所有建议。
注意:这只是伪代码,因为我只是想在深入了解我的项目之前了解这一点。
谢谢
罗斯
【问题讨论】:
标签: c# asp.net identity asp.net-mvc-5.1