【问题标题】:What is the difference between IdentityDbContext and IdentityDbContext<ApplicationUser> in MVC5MVC5 中的 IdentityDbContext 和 IdentityDbContext<ApplicationUser> 有什么区别
【发布时间】:2013-12-15 08:58:05
【问题描述】:

在 ASP.NET MVC5 应用程序中应该根据什么决定使用 IdentityDbContext 还是 IdentityDbContext&lt;ApplicationUser&gt;

使用IdentityDbContext&lt;ApplicationUser&gt; 代替非通用IdentityDbContext 有什么好处?

【问题讨论】:

  • "我们基于什么决定在 MVC5 应用程序中应该使用 IdentityDbContext 或 IdentityDbContext" 你打算在这里写 IdentityDbContext 吗?下一句你问福利的地方也一样?
  • 感谢@ChristopherHarris

标签: asp.net asp.net-mvc entity-framework asp.net-mvc-5 entity-framework-6


【解决方案1】:

IdentityDbContext&lt;ApplicationUser&gt; 将允许您使用自己的 ApplicationUser 类作为 User 实体。 IE。您可以在您的用户上拥有自定义属性。 IdentityDbContext 类继承自 IdentityDbContext&lt;IdentityUser&gt;,这意味着您必须为您的用户使用 IdentityUser 类。

如果您希望用户对象的属性比IdentityUser 提供的少数属性(用户名、密码哈希等)更多,那么您可能需要选择IdentityDbContext&lt;ApplicationUser&gt;

【讨论】:

    猜你喜欢
    • 2016-07-15
    • 1970-01-01
    • 2015-01-08
    • 1970-01-01
    • 1970-01-01
    • 2019-05-02
    • 1970-01-01
    • 1970-01-01
    • 2014-04-02
    相关资源
    最近更新 更多