What is the difference in the use of UserStore and UserManager in Asp.Net Identtity?

前端 未结 3 988
春和景丽
春和景丽 2020-12-23 21:03

I\'m very new to Asp.Net Identity and please bear with me if this question seems silly. So, when I read the definition for UserStore class and UserManager class in Microsoft

3条回答
  •  天涯浪人
    2020-12-23 21:36

    I was watching Identity tutorial on YouTube, and I think this screenshot might help:

    Managers vs Stores

    So UserManager is the actual class that you should work with but it does not know how to store and retrieve data from database. it even does not know where the data is going to and coming from.

    For those things it uses UserStore and says to it for example "Hey UserStore I have a new User that needs to be saved for future use, I don't know where you're going to save it and how you're going to do it, just save it for me"

    Then the UserStore does the actual work such as where should the data be saved? which database? and how? the default one uses EF and SQL Server so if you want to use some other database for example MySQL you're going to need a different UserStore.

    This is one of the features that were added to Identity compared to Membership that only worked with SQL Server.

    The same concept is true for RoleManager and RoleStore.

提交回复
热议问题