title: using EF Core IdentityContext and DbContext both for order management
body: <p>I am working on creating an ecommerce website on ASP MVC Core 2. I inherited my user from <code>IdentityUser</code> and inherited context from <code>IdentityDbContext</code> for working with user data and inherited a different context from <code>DbContext</code> for working with products and orders etc. </p>
  
  <p>Now, I want to link an order or shopping cart to a particular user and can not wrap my head around how to refer to the user in order table as they are in different contexts. I am also using the default guid created by EF as primary key in both the tables.</p>
  
  <p>Should I ditch <code>DbContext</code> and use <code>IdentityDbContext</code> only? Does doing this causes problems with async methods in identity and other usual non async methods.</p>
  
  <p>Here are some code snippets from my classes</p>
  
  
  
  <pre class="lang-cs prettyprint-override"><code>using Microsoft.AspNetCore.Identity;
  using System;
  using System.Collections.Generic;
  using System.ComponentModel.DataAnnotations;
  
  namespace shophe1.Models
  {
      public enum Gender { Male, Female, Other}
      public class User : IdentityUser
      {
          public string FullName { get; set; }
          public Gender Gender { get; set; }
          public string ReferralID { get; set; }
          public DateTime RegistrationDateTime { get; set; }
  
          public string ActivationDateTime { get; set; }
  
          public string UserType { get; set; }
          public Wallet Wallet {get;set;}
  
  
          public virtual ICollection&lt;UserBankDetail&gt; BankDetails { get; set; }
          public virtual ICollection&lt;UserAddress&gt; AddressDetails { get; set; }
         //public ShoppingCart Cart { get; set; }
          //public ICollection&lt;Order&gt; Orders { get; set; }
  
      }
  }
  </code></pre>
  
  <p><strong>Order class</strong></p>
  
  <pre class="lang-cs prettyprint-override"><code>using System.Collections.Generic;
  
  namespace shophe1.Models
  {
      public class Order
      {
          public string OrderId { get; set; }
          public ICollection&lt;product&gt; CartProducts { get; set; }
          //public User User { get; set; }
          public decimal OrderTotal { get; set; }
          public decimal ShippingCharges { get; set; }
      }
  }
  </code></pre>
  
  <p>The issue is if I add user in order model and a collection of orders in user class, both contexts get mixed up and when migrating, all user and product related models get clubbed in same migration whether I use DbContext or IdentityContext in migrations --context option. This is because both user and orders are now interrelated.</p>
  
  <p>Please advice.</p>