title: attempted to assign id from null one-to-one property: ContentItemRecord - Orchard CMS
body: <p>I'm writing the module for Orchard CMS.</p>
  
  <p>There are several tables. In Migrations.cs:</p>
  
  <p>It works fine:</p>
  
  <pre><code>            SchemaBuilder.CreateTable("CustomerPartRecord", table =&gt; table
              .ContentPartRecord()
              .Column&lt;string&gt;("FirstName", c =&gt; c.WithLength(50))
              .Column&lt;string&gt;("LastName", c =&gt; c.WithLength(50))
              .Column&lt;string&gt;("Title", c =&gt; c.WithLength(10))
              .Column&lt;DateTime&gt;("CreatedUtc")
              );
  
          ContentDefinitionManager.AlterPartDefinition("CustomerPart", part =&gt; part
              .Attachable(false)
              );
  
          ContentDefinitionManager.AlterTypeDefinition("Customer", type =&gt; type
              .WithPart("CustomerPart")
              .WithPart("UserPart")
              );
          return 6;
  </code></pre>
  
  <p>But it doesn't work:</p>
  
  <pre><code>            SchemaBuilder.CreateTable("OrderPartRecord", t =&gt; t
              .ContentPartRecord()
              .Column&lt;int&gt;("CustomerId", c =&gt; c.NotNull())
              .Column&lt;DateTime&gt;("CreatedAt", c =&gt; c.NotNull())
              .Column&lt;decimal&gt;("SubTotal", c =&gt; c.NotNull())
              .Column&lt;string&gt;("Status", c =&gt; c.WithLength(50).NotNull())
              );
  
          ContentDefinitionManager.AlterPartDefinition("OrderPart", part =&gt; part
               .Attachable(false)
          );
  
          ContentDefinitionManager.AlterTypeDefinition("Order", type =&gt; type
              .WithPart("OrderPart")
          );
  </code></pre>
  
  <p>There's error when I try to add Order. Error: <strong>attempted to assign id from null one-to-one property: ContentItemRecord</strong> What's wrong?</p>
  
  <p>UPD:</p>
  
  <p>Handler:</p>
  
  <pre><code>public class OrderPartHandler : ContentHandler
  {
      public OrderPartHandler(IRepository&lt;OrderPartRecord&gt; repository)
      {
          Filters.Add(StorageFilter.For(repository));
      }
  }
  </code></pre>
  
  <p>And creating Order:</p>
  
  <pre><code>_orderRepository.Create(order);
  </code></pre>