title: The property is part of the object's key information and cannot be modified
body: <p>I have the following model class, where its <code>NETWORKID</code> (PK) is not system generated:-</p>
  
  <pre><code>  public partial class NetworkInfo
      {
          public long NETWORKID { get; set; }
          public long WORKSTATIONID { get; set; }
          public string NICNAME { get; set; }
          public string NICDESCRIPTION { get; set; }
          public string IPADDRESS { get; set; }
          public string MACADDRESS { get; set; }
          public string IPNETMASK { get; set; }
          public string NETWORK { get; set; }
          public string GATEWAY { get; set; }
          public string ISDHCP { get; set; }
          public string DHCPSERVER { get; set; }
          public string NICLEASE { get; set; }
  
          public virtual Resource Resource { get; set; }
      }
  }
  </code></pre>
  
  <p>now i am saving the current networkinfo entities inside a list, then i want to add them again , by assigning new NetworkID to them. so i try the following :-</p>
  
  <pre><code>public void SaveAdditionalNeyworkInfo(long assetid, List&lt;NetworkInfo&gt; networkinfo) 
          {
              int i = 1;
              long max = entities.NetworkInfoes.Max(a =&gt; a.NETWORKID);
              foreach (var e in networkinfo.OrderBy(a=&gt;a.NETWORKID))
              {
                  if (i == 1)
                      i++;
                  else
                  {
                      e.NETWORKID = max + 1;
                      entities.NetworkInfoes.Add(e);
                      max++;
                  }
  
              }
  
          }
  </code></pre>
  
  <p>but this raise the following error:-</p>
  
  <pre><code>The property 'NETWORKID' is part of the object's key information and cannot be modified.
  </code></pre>
  
  <p>but if i re-write it as follow then i can add new entities :-</p>
  
  <pre><code>public void SaveAdditionalNeyworkInfo(long assetid, List&lt;NetworkInfo&gt; networkinfo) 
          {
              int i = 1;
              long max = entities.NetworkInfoes.Max(a =&gt; a.NETWORKID);
              foreach (var e in networkinfo.OrderBy(a=&gt;a.NETWORKID))
              {
                  if (i == 1)
                      i++;
                  else
                  {
                     NetworkInfo n = new NetworkInfo()
                     {
                         NETWORKID = max+1,
                         WORKSTATIONID = assetid,
                         NICNAME =e.NICNAME,
                          NICDESCRIPTION = e.NICDESCRIPTION,
                        IPADDRESS = e.IPADDRESS,
                          MACADDRESS=e.MACADDRESS,
                         IPNETMASK=e.IPNETMASK,
                          NETWORK=e.NETWORK,
                          GATEWAY=e.GATEWAY,
                         ISDHCP=e.ISDHCP,
                         DHCPSERVER=e.DHCPSERVER,
                         NICLEASE=e.NICLEASE
  
                     };
  
                   entities.NetworkInfoes.Add(n);
                     max++;
                  }
  
              }
  </code></pre>
  
  <p>so my question is why in the first approach i got an error that the NetworkID can not be modified , while in the second approach i did not get any error ? although in the two cases i am assign the NetworkID inside my code ?</p>