title: EF core : why add child row but automatically add parent row item?
body: <p>I add child row but automatic add row on parent table!</p>
  <p>I have 2 tables; child table is <code>Permission</code> and parent table is <code>Respondent</code>.</p>
  <p><code>Respondent</code> table is:</p>
  <pre><code>[Table(&quot;Respondent&quot;)]
  [Serializable]
  public class Respondent : IQuickSearchObject, IUIObject
  {
      #region Constructor
      public Respondent()
      {
          //چون ریکرسیو ایجاد میکنه نباید تو کانسترکتور نیو بشه
          // AccessGroupItem = new AccessGroup();
          //PersonItem = new Person();
          TradeFundID = -1;
          IsAdmin = false; //for all user except for مدیر سیستم
                           //MyAccountingConfig = new AccountingConfiguration();
          Permissions = new List&lt;Permission&gt;();
      }
   
      #endregion
   
      #region Property
   
      [DatabaseGeneratedAttribute(DatabaseGeneratedOption  .Identity)]
   
      [Key, ForeignKey(&quot;ID&quot;)]
      public long ID { get; set; }
      [Column(&quot;password&quot;)]
      public string Password { get; set; }
      [Column(&quot;accessGroupID&quot;)]
    //  [NotMapped]
      public long? accessGroupID { get; set; }
      [NotMapped]
      public virtual AccessGroup  AccessGroupItem { get; set; }
      [Column(&quot;personID&quot;)]
      public long? personID { get; set; }
      [NotMapped]
      public virtual Person PersonItem { get; set; }
      [NotMapped]
      public virtual List&lt;Permission&gt; Permissions { get; set; }
      #endregion
   
  }
  </code></pre>
  <p><code>Permission</code> table is:</p>
  <pre><code>[Table(&quot;Permission&quot;)]
  [Serializable]
  public class Permission : IQuickSearchObject
  {
            #region Constructor
            public Permission()
            {
                //چون ریکرسیو ایجاد میکنه نباید تو کانسترکتور نیو بشه
                this.AccessCodeItem = new AccessCode();
                this.AccessGroupItem = new AccessGroup();
                this.RespondentItem = new Respondent();
            }
  
            #region Properties
            [DatabaseGeneratedAttribute(DatabaseGeneratedOption  .Identity)]
   
            [Key, ForeignKey(&quot;ID&quot;)]
            public long ID { get; set; }
   
            [ForeignKey(&quot;RespondentID&quot;)]
            [Column(&quot;RespondentID&quot;)]
            [DatabaseGenerated(DatabaseGeneratedOption.None)]
            public long? RespondentID { get; set; }
            //{
            //    get { return RespondentItem.ID; }
            //    set { RespondentItem.ID = value; }
            //}
            [NotMapped]
            public virtual Respondent RespondentItem { get; set; }
            #endregion
  }
  </code></pre>
  <p>Relation is: one respondent entry to many permission entries.</p>
  <pre><code>modelBuilder.Entity&lt;Respondent&gt;()
               .HasMany(e =&gt; e.Permissions)
               .WithOne(e =&gt; e.RespondentItem)
               .HasForeignKey(e =&gt; e.RespondentID)
               .OnDelete(DeleteBehavior.NoAction);
  </code></pre>
  <p>add code is:</p>
  <pre><code>var AccessCodes = GetAccessCode(-1);
  
  foreach (var item in AccessCodes)
  {
      Permission newPermission = new Permission
                          {
                              AccessGroupItem = accessGroupAdmin,
                              AccessGroupID= accessGroupAdmin.ID,
                              AccessCodeItem = item,
                              AccessCodeID= item.ID,
                              EntityID = 0,
                              PermissionLevel = ArmanEnums.PermissionLevel.Allowed,
                              RespondentID = customerPerson.ID,
                          };
                          
      SetPermission(newPermission, adminID.ID, -1, 0) ;
  }
  
  
  
   public long SetPermission(Permission newPermission, long userID, int transactionID, long serverOperationID)
          {
              var id = 0L;
              var newItem = _dbLayer.UnitControlItem.PermissionRepository.Insert(newPermission);
              _dbLayer.UnitControlItem.PermissionRepository.Save();
              id = newItem.ID;
              if (id != 0)
                  SetDataLog(
                      new DataLog(id, Command.Set, EntityType.Permission, &quot;&quot;),
                      userID, transactionID, serverOperationID);
              return id;
          }
  </code></pre>
  <p><a href="https://i.stack.imgur.com/c1JSK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/c1JSK.png" alt="SQLData" /></a></p>
  <p><a href="https://i.stack.imgur.com/yHJf0.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yHJf0.png" alt="Database" /></a></p>
  <p>why add automaticly add row on Respondent Table!</p>