If you use an “ID” field in your entity, & this “ID” field is not auto-increament, Entity Framework will fail when generate insert sql.
Solve:
Add a DatabaseGeneratedAttribute to this “ID” field, with DatabaseGeneratedOption.None option, like this:
1 2 3 4 5 6 7 | public abstract class BaseAccount { [Key] [DatabaseGenerated(DatabaseGeneratedOption.None)] public int ID { get; set; } ...... } |
Successfully solved under Entity Framework 4-6.