title: DDD - How to manage entities across bounded contexts in EF Core
body: <p>I have not found concrete examples of this. I know that each bounded context has its own versions of entities and you should not share entities across contexts. But how do I manage this in relation to using an ORM like EF?</p>
  
  <p>For example, below are my entities and bounded contexts they exist in:</p>
  
  <p>Ingredient (entity bounded context A)</p>
  
  <p>Recipe (entity bounded context b)<br>
  Ingredient (entity  bounded context b)<br>
  MenuItem (aggregate bounded context b)</p>
  
  <p>Now each bounded context will have its own version of ingredient. But since I have a singular DB context in EF for managing this, how exactly do I arrange this? I am using CQRS so I can trigger events if needed. My plan was to maintain a list of ids in my Recipe entity and pull in the relevant Ingredients from the database so that data is not duplicated.  </p>
  
  <p>But I'm not sure if my data duplication concern is valid. In my example above, imagine a business which sells ingredients but also has preset recipes (with a list of ingredients) that it can sell in a food stall.</p>
  
  <p>In one context, ingredients has no relation to another entity while in another context its a child entity (in an aggregate). I can see how it should be designed (separate entities in bounded contexts) but when it comes to the DB, how is this actually setup? What if the properties/domain knowledge that need to be tracked in context A vs context B for ingredients is different? Will this end up being a separate table? I'm a bit lost on this.</p>
  
  <p>Edit:
  Please keep in mind I'm only using 1 database here. I understand that usually you have separate DB per bounded context to avoid this scenario but was wondering how this can be accomplished via 1 DB.</p>