1

I have made a question few days ago on how to make a many-to-many relationship between the Asp.Net Identity table and my custom table.

Here the thread with the answer: Q&A

Someone told me that from an architectural point of view it's best to handle user information and business data separately. I quote: "That said from an architectural point of view it seems best to handle user information and business data separately, I would perhaps rather aggregate both behind a facade but keep them separate under the scene"

In the answer someone gave me, which is a solution, he told me to use the ApplicationDbContext to work with the tables, etc.

Now going back to what the other person said me, I want to keep my hands away from the ApplicationDbContext, which is the Identity context, and work only with my own context.

Can someone give me a workaround how to archive that? Thank you!

Community
  • 1
  • 1
Arianit
  • 543
  • 2
  • 8
  • 24
  • 2
    *"from an architectural point of view it's best to handle user information and business data separately"* That's a bit of an opinionated statement. Unless you have a large database I'd stick with a single context. – DavidG Sep 26 '16 at 09:13
  • Let's stick with the idea I have a large database – Arianit Sep 26 '16 at 09:14
  • So you're asking how to use two contexts inside the same application? – Tim Reynolds Sep 26 '16 at 09:18
  • @TimReynolds yes and no. Better say to use my own context to make the relationship with the AspNetUser table and my own table – Arianit Sep 26 '16 at 09:20
  • 1
    @Arianit as DavidG points out you're best with a single context. However if you want to do this it depends on your use case, lets assume you want to use all of EF relationship behaviour for loading items related to a User the easiest thing you could so is add a more selective user model to the context. If you're following DDD and tread both as bounded contexts you'd probably create another user table with the information related to users use of the application – Tim Reynolds Sep 26 '16 at 09:25
  • @TimReynolds that makes sense. Can you maybe show me how to with an example please? – Arianit Sep 26 '16 at 09:30

0 Answers0