I have a table whose primary key id is an identity column. I think that when a new record is created, id will be incremented by 1.
However I found that it is 0 while debugging. Why?
The necessary code:
public DbSet<testDetails> testDetailRecords { get; set; }
testDetails test = testContext.testDetailRecords.Create();
// test.id is 0 when hover over it
public class testDetails : IEntityWithRelationships
{
[Key]
[Required]
[Display(Name = "Primary Key", Description = "Primary Key")]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public long id { get; set; }
The record is not created until you commit it with a
SaveChanges().