By default, Scaffolding a table with an auto-increment field adds:
.ValueGeneratedNever();
To the field in the Model Builder. This will cause an automatic value NOT to be generated. This needs to be removed.
Also, we need to add:
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int? TemplateId { get; set; }
To the item – and ensure it is a nullable int. https://docs.microsoft.com/en-us/ef/core/modeling/generated-properties …