title: entity framework code first double one to one relationship
body: <pre><code>class Event{  
      int? EventID{get;set;}  
      int? FirstParticipantID{get;set;}  
      Participant FirstParticipant{get;set;}  
      int? SecondParticipantID{get;set;}  
      Participant SecondParticipant{get;set;}  
      int? CreatedByID{get;set;}  
      User CreatedBy{get;set;}  
  }
  
  
  class Participant{  
      int? ParticipantID{get;set;}  
      List&lt;Event&gt; Events{get;set;}  
      int? CreatedByID{get;set;}  
      User CreatedBy{get;set;}  
  }
  
  protected override void OnModelCreating(DbModelBuilder modelBuilder){  
      modelBuilder.Entity&lt;Event&gt;().HasRequired(m =&gt; m.FirstParticipant).WithMany(m =&gt; m.Events).HasForeignKey(m =&gt; m.FirstParticipantID);  
      modelBuilder.Entity&lt;Event&gt;().HasRequired(m =&gt; m.SecondParticipant).WithMany(m =&gt; m.Events).HasForeignKey(m =&gt; m.SecondParticipantID);  
      modelBuilder.Entity&lt;Event&gt;().HasRequired(m =&gt; m.CreatedBy);  
      modelBuilder.Entity&lt;Participant&gt;().HasRequired(m =&gt; m.CreatedBy);  
  }
  </code></pre>
  
  <p>It seems very clear to me, but EF (and sql) keeps complaining, no matter what moves I make to the hasmanny/hasrequired stuff. I can't even find google help cause I don't know the name of what I'm trying to implement (double one to one???!!!)  </p>
  
  <p>The idea is that an Event must have 2 not null Participants (first &amp; second only, not many) and that each Participant may have many Events  </p>
  
  <p>Thanks</p>