title: EF Core entity not added to database
body: <p>My entities are not added to a specific table.</p>
  
  <p>While every other tables are working great, I have a specific one which is not and I can't find out why. In a same sequence, I have different add/update before a <code>SaveChangeAsync</code>, every query works fine except for one table where entities are not added.</p>
  
  <p>I have checked the entity, its data is well filled.  </p>
  
  <p>After some investigations on why I had no data in this table, I used the immediate window to perform some tests, here is what I get for the sequence:</p>
  
  <ol>
  <li>Count from table</li>
  <li>Add an entity</li>
  <li>Save <code>DBContext</code></li>
  <li>Count from table</li>
  </ol>
  
  <p><strong>Count</strong> </p>
  
  <pre><code>_DbContext.Attendees.Count()
  Microsoft.EntityFrameworkCore.Database.Command:Information: Executed DbCommand (17ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
  SELECT COUNT(*)
  FROM [Attendees] AS [e]
  Application Insights Telemetry (unconfigured): {"name":"Microsoft.ApplicationInsights.Dev.Message","time":"2018-05-02T11:39:35.5327129Z","tags":{"ai.operation.parentId":"|d06def47-4faba4501b66147c.","ai.operation.id":"d06def47-4faba4501b66147c","ai.location.ip":"127.0.0.1","ai.operation.name":"POST Order/VerifyPayment [cartId]","ai.application.ver":"1.0.0.0","ai.internal.nodeName":"MyPC","ai.cloud.roleInstance":"MyPC","ai.internal.sdkVersion":"aspnet5c:2.1.1"},"data":{"baseType":"MessageData","baseData":{"ver":2,"message":"Executed DbCommand (17ms) [Parameters=[], CommandType='Text', CommandTimeout='30']\r\nSELECT COUNT(*)\r\nFROM [Attendees] AS [e]","severityLevel":"Information","properties":{"{OriginalFormat}":"Executed DbCommand ({elapsed}ms) [Parameters=[{parameters}], CommandType='{commandType}', CommandTimeout='{commandTimeout}']{newLine}{commandText}","elapsed":"17","commandTimeout":"30","commandText":"SELECT COUNT(*)\r\nFROM [Attendees] AS [e]","AspNetCoreEnv
  ironment":"Development","commandType":"Text","DeveloperMode":"true","CategoryName":"Microsoft.EntityFrameworkCore.Database.Command"}}}}
  0
  </code></pre>
  
  <p><strong>Add entity</strong></p>
  
  <pre><code>_DbContext.Attendees.Add(attendees[0])
  {Microsoft.EntityFrameworkCore.ChangeTracking.Internal.InternalClrEntityEntry}
      Collections: {System.Linq.Enumerable.WhereSelectEnumerableIterator&lt;Microsoft.EntityFrameworkCore.Metadata.INavigation, Microsoft.EntityFrameworkCore.ChangeTracking.CollectionEntry&gt;}
      Context: {Project.Data.DbContext}
      CurrentValues: {Microsoft.EntityFrameworkCore.ChangeTracking.Internal.CurrentPropertyValues}
      Entity (Microsoft.EntityFrameworkCore.ChangeTracking.EntityEntry): {Project.Models.Attendee}
      Entity: {Project.Models.Attendee}
      InternalEntry: {Microsoft.EntityFrameworkCore.ChangeTracking.Internal.InternalClrEntityEntry}
      IsKeySet: true
      Members: {System.Linq.Enumerable.Concat2Iterator&lt;Microsoft.EntityFrameworkCore.ChangeTracking.MemberEntry&gt;}
      Metadata: {EntityType: Attendee}
      Navigations: {System.Linq.Enumerable.SelectEnumerableIterator&lt;Microsoft.EntityFrameworkCore.Metadata.INavigation, Microsoft.EntityFrameworkCore.ChangeTracking.NavigationEntry&gt;}
      OriginalValues: {Microsoft.EntityFrameworkCore.ChangeTracking.Internal.OriginalPropertyValues}
      Properties: {System.Linq.Enumerable.SelectEnumerableIterator&lt;Microsoft.EntityFrameworkCore.Metadata.IProperty, Microsoft.EntityFrameworkCore.ChangeTracking.PropertyEntry&gt;}
      References: {System.Linq.Enumerable.WhereSelectEnumerableIterator&lt;Microsoft.EntityFrameworkCore.Metadata.INavigation, Microsoft.EntityFrameworkCore.ChangeTracking.ReferenceEntry&gt;}
      State: Added
  </code></pre>
  
  <p><strong>Save changes</strong></p>
  
  <pre><code>_DbContext.SaveChanges()
  0
  </code></pre>
  
  <p><strong>Table Count</strong></p>
  
  <pre><code>_DbContext.Attendees.Count()
  Microsoft.EntityFrameworkCore.Database.Command:Information: Executed DbCommand (19ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
  SELECT COUNT(*)
  FROM [Attendees] AS [e]
  Application Insights Telemetry (unconfigured): {"name":"Microsoft.ApplicationInsights.Dev.Message","time":"2018-05-02T11:40:05.8741131Z","tags":{"ai.operation.parentId":"|d06def47-4faba4501b66147c.","ai.operation.id":"d06def47-4faba4501b66147c","ai.location.ip":"127.0.0.1","ai.operation.name":"POST Order/VerifyPayment [cartId]","ai.application.ver":"1.0.0.0","ai.internal.nodeName":"MyPC","ai.cloud.roleInstance":"MyPC","ai.internal.sdkVersion":"aspnet5c:2.1.1"},"data":{"baseType":"MessageData","baseData":{"ver":2,"message":"Executed DbCommand (19ms) [Parameters=[], CommandType='Text', CommandTimeout='30']\r\nSELECT COUNT(*)\r\nFROM [Attendees] AS [e]","severityLevel":"Information","properties":{"{OriginalFormat}":"Executed DbCommand ({elapsed}ms) [Parameters=[{parameters}], CommandType='{commandType}', CommandTimeout='{commandTimeout}']{newLine}{commandText}","elapsed":"19","commandTimeout":"30","commandText":"SELECT COUNT(*)\r\nFROM [Attendees] AS [e]","AspNetCoreEnv
  ironment":"Development","commandType":"Text","DeveloperMode":"true","CategoryName":"Microsoft.EntityFrameworkCore.Database.Command"}}}}
  0
  </code></pre>
  
  <p>As we can observe, the entity is attached successfully, but on save, nothing happens... What could cause this? It is declared as any other table. It has a Guid Id as key, which is set on code-side</p>
  
  <p><strong>Additional information</strong></p>
  
  <pre><code>_DbContext.ChangeTracker.Entries&lt;Attendee&gt;().Count() =&gt; 1
  </code></pre>
  
  <p>and</p>
  
  <pre><code>_DbContext.ChangeTracker.Entries&lt;Attendee&gt;().ElementAt(0).Entity
  </code></pre>
  
  <p>gives an entity, with a set unique id and many other fields which have not much interest in this case.</p>
  
  <p>After a <code>Save</code>, Entries.Count returns 0, but nothing has been added...</p>
  
  <p>I have removed any foreign key in SQL that could interfere and any key besides primary key in the entity description.</p>
  
  <p><code>_DbContext.Attendees.FirstOrDefault()</code> runs the SQL statement, and returns null as expected as there is no entry in the DB.</p>
  
  <p>If I do <code>_DbContext.Attendees.Add(new Attendee(){Id=Guid.NewId()})</code> it works... I will start from there...</p>