.NET Core Identity. Use one context or two?

爱⌒轻易说出口 提交于 2021-01-28 12:11:56

问题


I am struggling with a basic problem. Keep my ASP.NET Core Identity context separate from my business context or combine the two.

Philosophically, it seems good to keep them separate. If I want to upgrade .NET Core at some point in the future, I have fewer issues if my identity context is separate.

Practically, it seems like a good idea to combine them. Otherwise, I am creating another user table or doing some weird workarounds to get user information from navigation properties.

How do you handle Identity contexts in .NET Core?


回答1:


In my experience, its a good idea to keep identity context, separate from your business logic.

  • You will probably have to do some expensive encryption and other things on your identity database. There may be no need to apply such encryption to your business data
  • You might choose to replace, have separate backup plans and recovery plans for your identity database. non-identity database may have its own plan.
  • More importantly, one fine day, you might decide and go with a 3rd party auth provider and forget about managing identity yourself. At which point, you may do some migration, throw away the identity database as it is no longer needed.

So, yes, best to use different context/database.

note : I am assuming, each context is linked to a different database. This is a given, but, for the sake of clarity, putting it here.



来源:https://stackoverflow.com/questions/64083720/net-core-identity-use-one-context-or-two

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!