Search code examples
asp.net-mvc-4entity-framework-5asp.net-membershipentity-framework-6simplemembership

Create two joined tables with ASPNetUsers table or to extend the ASPNETUsers table?


The application should have customers and sellers and another table for goods/items, First scenario is to extend the AspNetUsers and make it usable for both customers and sellers and differentiate between them by one field added to AspNetUsers (could name it "PrsnType" as an example), this tutorial show how to extend ApplicationUser class so reflect on AspNetUsers tbl: http://www.itorian.com/2013/11/customize-users-profile-in-aspnet.html

Or the Another scenario is to create tow tables one for customer and another for seller and join them with AspNetUsers table by ID, according to what is this tutorial : http://www.itorian.com/2013/11/customizing-users-profile-to-add-new.html

I like to go with first scenario, but I am afraid to face problems with database relation or when try to reach a related/joined field by EF.

Please advice me what is the best solution to go with and why?


Solution

  • Until have any new good answer, I will share my experience during last 48 hours: According to some research on the internet, And after I tried the both above solution it is better to have different tables for customers and sellers and make each table join the ApplicationUser (1 to 1), because if you go with first solution (rely on AspNetUsers table by add some fields to it(or to ApplicationUser) and add field "typeID" to differentiate between sellers and customers) you will have problems regarding tables relation especially join ApplicationUser with other tables in EF.

    Also,Please check this new good article : http://travis.io/blog/2015/03/24/migrate-from-aspnet-membership-to-aspnet-identity.html