title: CQRS DDD - Commands and Domain Models relationship
body: <p>I'm practicing to implement a project using CQRS and DDD to the best I can and have come up with a question once building the commands. </p>
  
  <p><strong>Scenario:</strong> The user sends a command to create a bookshelf in the system which itself could also contain a collection of books.</p>
  
  <p>The command looks like this:</p>
  
  <pre><code>public class CreateNewBookShelfCommand : ICommand
  {
      public long CommandInitiatorId { get; set; }
      public string Name { get; set; }
      public string Description { get; set; }
      public ICollection&lt;Book&gt; Books { get; set; }
  }
  </code></pre>
  
  <p>All of the <code>Commands</code> reside in the <code>Contracts</code> project that itself is inside the <code>Application</code> solution folder.</p>
  
  <p>The <code>Model</code> project residing in the <code>Domain</code> solution folder hosts the <code>BookShelf</code> entity class which includes a collection of Books.</p>
  
  <p><strong>Questions 1:</strong>  The command above has this <code>Books</code> property which is of type <code>Book</code>. My question is: should the <code>Commands</code> project directly reference the Model project so that the <code>Book</code> data type would be resolved in the <code>CreateNewBookShelfCommand</code>? Myself, I don't think that the <code>Contracts</code> are allowed to reference any project other than the <code>CommandHandlers</code> or anything else which might be <em>Cross Cutting</em>. </p>
  
  <p><strong>Question 2:</strong> So, is this a good practice to replicate part of the <code>Book</code> entity class here at the <code>Contracts</code> project and utilize it in the <code>CreateNewBookShelfCommand</code>? </p>
  
  <p>And this is the Model project I have for <code>Book</code> and <code>BookShelf</code>:</p>
  
  <pre><code>public class BookShelf : BaseEntity
  {
      public string Name { get; set; }
      public string Description { get; set; }
      public BookShelfAccess Access { get; set; }
  
      public virtual BookShelfOwner Owner { get; set; }
      public long OwnerId { get; set; }
  
      public ICollection&lt;Book&gt; Books { get; set; }
  }
  
   public class Book : BaseEntity
  {
      public string Name { get; set; }
      public DateTime? PublishedAt { get; set; }
      public int NumberOfPublishes { get; set; }
  
      public virtual BookShelf Shelf { get; set; }
      public long ShelfId { get; set; }
  }
  </code></pre>
  
  <p>I hope my explanation has been enough if there is any other information I should add here let me know. </p>