How do I integrate Membership tables with Entity Framework? Asp.net

后端 未结 2 921
伪装坚强ぢ
伪装坚强ぢ 2020-12-18 06:05

I have never used Entity Framework in a project before so I am not sure where to begin. I have I am using the membership tables that are created when using ASP.Net membershi

相关标签:
2条回答
  • 2020-12-18 06:39

    I would say you could create an "AppUser"(Your own custom User object) Entity where the corresponding table has a foreign key to the "UserID" column of the aspnet_Membership table. This way it will be easier if you need to change or add properties to your "AppUser" Entity instead of trying to change the MS table structure (which can be a real pain). You can still interact with the built-in MS Membership classes and functions from your MVC project using something like the MvcMembership starter Kit DLL's.

    https://github.com/TroyGoode/MembershipStarterKit

    Hope this helps!

    0 讨论(0)
  • 2020-12-18 06:44

    If you want to have one EF model which links your membership tables and application tables, you can add the ASP.NET Membership tables to your existing database using the aspnet_regsql.exe utility. Some links:

    • MSDN documentation
    • Tutorial on the ASP.NET website

    Once you have the Membership tables installed, you can generate EF Code classes that match the membership schema. I posted a detailed walkthrough on how to do that here:

    Generating EF Code First model classes from an existing database

    0 讨论(0)
提交回复
热议问题