title: How to get Entity Framework Code First and nullable foreign key properties to work?
body: <p>I'm trying to create a simple entity framework code first application. I have these classes:</p>
  
  <pre><code>public class User
  {
      public int UserId { get; set; }
  
      public string Username { get; set; }
  
      public virtual ActivationTicket ActivationTicket { get; set; }
  }
  
  public class ActivationTicket
  {
      public int ActivationTicketId { get; set; }
  
      public virtual User User { get; set; }
  
      public string Ticket { get; set; }
  }
  </code></pre>
  
  <p>When I try to create a new user and save it to the database (a user without a ActivationTicket that is) I receive an exception </p>
  
  <blockquote>
    <p>The INSERT statement conflicted with the FOREIGN KEY constraint "ActivationTicket_User". The conflict occurred in database "Test", table "dbo.ActivatioTickets", column 'ActivationTicketId'. The statement has been terminated.</p>
  </blockquote>
  
  <p>I assume EF treats the mapping between User and ActivationTicket as 1-1 but it should be 1-0..1</p>
  
  <p>What do I have to do to get this to work?</p>