title: multiplicity conflicts with referential constraint in Role
body: <p>The Error message which i am getting is following -----
  <strong>MVCRegistration.Models.Post_UserProfile: : Multiplicity conflicts with the referential constraint in Role 'Post_UserProfile_Target' in relationship 'Post_UserProfile'. Because all of the properties in the Dependent Role are non-nullable, multiplicity of the Principal Role must be '1'.
  MVCRegistration.Models.PostComment_UserProfile: : Multiplicity conflicts with the referential constraint in Role 'PostComment_UserProfile_Target' in relationship 'PostComment_UserProfile'. Because all of the properties in the Dependent Role are non-nullable, multiplicity of the Principal Role must be '1'.</strong>
  here, MVCRegistraion is solution file name.</p>
  
  <p>Now, i have three classes like this---</p>
  
  <pre><code> public class UserProfile
  {
      public UserProfile()
      {
          this.PostComments = new HashSet&lt;PostComment&gt;();
          this.Posts = new HashSet&lt;Post&gt;();
      }
      [Key]
      [DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
      public int UserId { get; set; }
      public string UserName { get; set; }
      public string AvatarExt { get; set; }
      public virtual ICollection&lt;PostComment&gt; PostComments { get; set; }
      public virtual ICollection&lt;Post&gt; Posts { get; set; }
  }
  </code></pre>
  
  <p>and the post class is something like this----</p>
  
  <pre><code>    public class Post
      {
      public Post()
      {
          this.PostComments = new HashSet&lt;PostComment&gt;();
      }
      [Key]
      public int PostId { get; set; }
      public string Message { get; set; }
      public int PostedBy { get; set; }
      public System.DateTime PostedDate { get; set; }
      public virtual ICollection&lt;PostComment&gt; PostComments { get; set; }
      public virtual UserProfile UserProfile { get; set; }
    }
  </code></pre>
  
  <p>and PostComment is----</p>
  
  <pre><code>   public class PostComment
  {
      [Key]
      public int CommentId { get; set; }
      public int PostId { get; set; }
      public string Message { get; set; }
      public int CommentedBy { get; set; }
      public System.DateTime CommentedDate { get; set; }
      public virtual Post Post { get; set; }
      public virtual UserProfile UserProfile { get; set; }
  }
  </code></pre>
  
  <p>I have configured one to many relationship betwween USerProfile class and Post class like this using fluent api---</p>
  
  <pre><code>        modelBuilder.Entity&lt;Post&gt;()
                     .HasOptional&lt;UserProfile&gt;(u =&gt; u.UserProfile)
                     .WithMany(p =&gt; p.Posts)
                     .HasForeignKey(s =&gt; s.PostedBy);
  </code></pre>
  
  <p>and one to many relationship between USerProfile and Post comment class like this-----</p>
  
  <pre><code>    modelBuilder.Entity&lt;PostComment&gt;()
                    .HasOptional&lt;UserProfile&gt;(u =&gt; u.UserProfile)
                    .WithMany(p =&gt; p.PostComments)
                    .HasForeignKey(s =&gt; s.CommentedBy);
  </code></pre>
  
  <p>Now, i am frustated figuring out what is going on here. It is so simple looking in code first to create foreign key with name PostedBy but entity framework is making things worse.Dont know what entity framework need now.</p>