title: How to manage new Breeze entities which are aggregate roots?
body: <p>I have a domain model which has a Customer, which in turn has 1 Address (1:1) and 1 or more Phone numers (1:M).
  Customer has user supplied PK (a string), while Address and Phone use identity column (server generated).</p>
  
  <p>I am struggling in trying to understand how to manage Breeze entity creation for a "Add new Customer" screen.
  The form on the screen allows user to enter Customer, Address, and Phone data.</p>
  
  <p>I am using Durandal and Knockout so my "customeradd.js" viewmodel looks something like this:</p>
  
  <pre><code>// -- snip ---
      var customer = ko.observable(),
          hasChanges = ko.computed(function () {
              return datacontext.hasChanges();
          });
  
      var vm = {
          hasChanges: hasChanges,
          customer: customer,
          activate: activate
      };
  
      return vm;
  
      function activate() {
          customer(datacontext.createCustomer());
      }
  // -- snip ---
  </code></pre>
  
  <p>and my "/services/datacontext.js" :</p>
  
  <pre><code>// -- snip ---
      breeze.NamingConvention.camelCase.setAsDefault();
  
      var manager = new breeze.EntityManager(config.remoteServiceName);
      var hasChanges = ko.observable(false);
  
      manager.hasChangesChanged.subscribe(function (eventArgs) {
          hasChanges(eventArgs.hasChanges);
      });
  
      function createVehicle() {
          return manager.createEntity("Customer");
      }
  // -- snip ---
  </code></pre>
  
  <p>My questions are following:</p>
  
  <ul>
  <li>Once I create a Customer, do I need to create Address and list of Phones and add them to Customer entity before making it a KO observable? Or is this done automatically by createEntity() method?</li>
  <li>How do I create a Customer but without having to specify the Id? If I set the key to null or '', Breeze complains ("Error: Cannot attach an object to an EntityManager without first setting its key or setting its entityType 'AutoGeneratedKeyType' property to something other than 'None'"). However, if I generate the temp key (using either breeze.core.getUuid() or something else), then it shows up in my Id form field, and I really want the end user to specify it....Do I have to resort to extending the entity with extra field and then do the swapping and validation before saving (I don't like this idea at all)? Is there a better way?</li>
  <li>In order to enable/disable buttons on my form I am tracking if there are changes in EntityManager. But every time entity is created, it is automatically in 'added' state so hasChanges is true. What I want is for changes to be picked up only if user edits the form (and therefore makes changes to underlaying entity). What is the best way to approach this?</li>
  </ul>
  
  <p>BTW, I have seen <a href="https://stackoverflow.com/a/16054604/481904">this recommendation</a> to register custom constructor for entity (I have already implemented it but I am still not clear how to let user supply their own id and to flag entity as modified only when user edits it...)</p>