【问题标题】:Create two joined tables with ASPNetUsers table or to extend the ASPNETUsers table?使用 ASPNetUsers 表创建两个连接表或扩展 ASPNETUsers 表?
【发布时间】:2015-06-19 20:56:45
【问题描述】:

应用程序应该有客户和卖家以及另一个商品/物品表, 第一种情况是扩展 AspNetUsers 并使其对客户和卖家都可用,并通过添加到 AspNetUsers 的一个字段来区分它们(可以将其命名为“PrsnType”作为示例), 本教程展示了如何扩展 ApplicationUser 类以反映 AspNetUsers tbl: http://www.itorian.com/2013/11/customize-users-profile-in-aspnet.html

或者另一种情况是为客户创建两个表,另一个为卖方创建两个表,并按照 ID 将它们与 AspNetUsers 表连接起来,根据本教程的内容: http://www.itorian.com/2013/11/customizing-users-profile-to-add-new.html

我喜欢第一种情况,但我害怕遇到数据库关系问题或尝试通过 EF 访问相关/连接字段时。

请告诉我什么是最好的解决方案,为什么?

【问题讨论】:

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


    【解决方案1】:

    在有任何新的好答案之前,我将分享我在过去 48 小时内的经验: 根据对internet 的一些研究,在我尝试了上述两种解决方案之后,最好为客户和卖家提供不同的表,并使每个表加入 ApplicationUser(1 到 1),因为如果你使用第一个解决方案(依赖 AspNetUsers 表,通过向其(或 ApplicationUser)添加一些字段并添加字段“typeID”来区分卖家和客户)您将在表关系方面遇到问题,尤其是将 ApplicationUser 与 EF 中的其他表连接起来。

    另外,请查看这篇新的好文章: http://travis.io/blog/2015/03/24/migrate-from-aspnet-membership-to-aspnet-identity.html

    【讨论】:

      猜你喜欢
      • 2016-08-17
      • 1970-01-01
      • 2017-12-12
      • 2020-06-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-06-05
      • 1970-01-01
      相关资源
      最近更新 更多