title: Fluent NHibernate Many to Many insert issue
body: <p>I have UserModel and RoleModel. I thinked thay may be in many to many relationship 'cause Users can have more than one role and a role can has more than one User. I make it Many to many but when i try insert a user i'm getting error like:</p>
  
  <blockquote>
    <p>INSERT statement FOREIGN KEY constraint "FK6209393F7EB4E792" coincided with. "projectcoderwho" database "dbo.roles" column 'Id' There was an overlap in the table.
    The statement has been terminated.</p>
  </blockquote>
  
  <p>I search it some but nothing usefull for me or I can't see the somethings.
  Now has anyone an idea about my problem?</p>
  
  <p>This codes worked only one time. But now I'm getting the error which above.</p>
  
  <p>UserModel.cs:</p>
  
  <pre><code>public class UserModel
  {
      public virtual int Id { get; set; }
      public virtual DateTime RegisterDate { get; set; }
      public virtual string RegisterIp { get; set; }
      public virtual string EMail { get; set; }
      public virtual string Password { get; set; }
      public virtual string UserName { get; set; }
      public virtual string FirstName { get; set; }
      public virtual string LastName { get; set; }
      public virtual string WebSiteLink { get; set; }
      public virtual string FaceBookLink { get; set; }
      public virtual string TwitterLink { get; set; }
      public virtual string GooglePlusLink { get; set; }
      public virtual string PinterestLink { get; set; }
      public virtual IList&lt;RoleModel&gt; UserRole { get; set; }
      public virtual DateTime LastLogIn { get; set; }
      public virtual string LastLoginIP { get; set; }
      public virtual string About { get; set; }
      public virtual bool IsActive { get; set; }
      public virtual bool IsFreelancer { get; set; }
      public virtual bool IsBanned { get; set; }
  
      public UserModel()
      {
          UserRole = new List&lt;RoleModel&gt;();
      }
  
  }
  </code></pre>
  
  <p>RoleModel.cs</p>
  
  <pre><code>public class RoleModel
  {
      //will contains as default: Admin,Moderator,Author,User
      public virtual int Id { get; set; }
      public virtual string RoleName { get; set; }
      public virtual IList&lt;UserModel&gt; UsersInRole { get; set; }
  
      public RoleModel()
      {
          UsersInRole = new List&lt;UserModel&gt;();
      }
  }
  </code></pre>
  
  <p>UserModelMap.cs:</p>
  
  <pre><code>public class UserModelMap : ClassMap&lt;UserModel&gt;
  {
      public UserModelMap()
      {
          Table("Users");
  
          Id(x =&gt; x.Id);
  
          Map(x =&gt; x.RegisterDate);
          Map(x =&gt; x.RegisterIp);
          Map(x =&gt; x.EMail);
          Map(x =&gt; x.Password);
          Map(x =&gt; x.UserName);
          Map(x =&gt; x.FirstName);
          Map(x =&gt; x.LastName);
          Map(x =&gt; x.WebSiteLink);
          Map(x =&gt; x.FaceBookLink);
          Map(x =&gt; x.TwitterLink);
          Map(x =&gt; x.GooglePlusLink);
          Map(x =&gt; x.PinterestLink);
          Map(x =&gt; x.LastLogIn);
          Map(x =&gt; x.LastLoginIP);
          Map(x =&gt; x.About);
          Map(x =&gt; x.IsActive);
          Map(x =&gt; x.IsFreelancer);
          Map(x =&gt; x.IsBanned);
  
          HasManyToMany(x =&gt; x.UserRole).Table("UsersRoles")
              .ParentKeyColumn("RoleId")
              .ChildKeyColumn("UserId")
              .LazyLoad()
              .Cascade.All();
      }
  }
  </code></pre>
  
  <p>RoleModelMap.cs:</p>
  
  <pre><code>public class RoleModelMap : ClassMap&lt;RoleModel&gt;
  {
      public RoleModelMap()
      {
          Table("Roles");
  
          Id(x =&gt; x.Id);
  
          Map(x =&gt; x.RoleName);
  
          HasManyToMany(x =&gt; x.UsersInRole).Table("UsersRoles")
              .ParentKeyColumn("RoleId")
              .ChildKeyColumn("UserId")
              .LazyLoad()
              .Inverse();
      }
  }
  </code></pre>
  
  <p>In UserApiController.cs:</p>
  
  <pre><code>[Route("User/Register")]
  [HttpPost]
  public string RegisterUser(object regUser)
  {
      RoleModel userRole = BlogModule.getUserRole();//Getting "User" role
      UserModel newUser = JsonConvert.DeserializeObject&lt;UserModel&gt;(regUser.ToString());
      string hashedPassword = BlogModule.PasswordToMD5(newUser.Password);
      newUser.Password = hashedPassword;
      newUser.RegisterDate = DateTime.Now;
      newUser.UserRole.Add(userRole);
      newUser.LastLogIn = DateTime.Now;
      newUser.LastLoginIP = newUser.RegisterIp;
  
  
      DbOperations.AddNewUserToDatabase(newUser);
  
      string sonuc = "true";
      return sonuc;
  }
  </code></pre>
  
  <p>AddNewUserToDatabase(UserModel newUser):</p>
  
  <pre><code>public static void AddNewUserToDatabase(UserModel newUser)
  {
      using (var session = NHibernateHelper.OpenSession())
      {
          using (var transaction = session.BeginTransaction())
          {
  
              UserModel currentUser = session.QueryOver&lt;UserModel&gt;()
                  .Where(x =&gt; x.UserName == newUser.UserName)
                  .SingleOrDefault();
              if (currentUser == null)
              {
                  session.Save(newUser);
                  transaction.Commit();
              }
          }
      }
  }
  </code></pre>