1

We are using .Net Framework 4.6.1 and EF 6.1.3, code first approach in our application. I have following entity

public class ArchiveBaseEntity
    {
        public int Id { get; set; }
        public DateTime CreatedOn { get; set; }
        public int? CreatedBy { get; set; }
        public DateTime? ModifiedOn { get; set; }
        public int? ModifiedBy { get; set; }
    }

When I create migration, I want that Id is primary key, but not to be auto increment. As you can assume from name of the entity, I want to archive, and want to copy exact Id from original db.

user1698635
  • 145
  • 2
  • 12
  • 4
    I believe this answer has what you need, with responses covering both annotations and FluentApi: https://stackoverflow.com/questions/7206273/disabling-identity-auto-incrementing-on-integer-primary-key-using-code-first – Bryan Lewis Feb 13 '20 at 16:07
  • 1
    Does this answer your question? [Disabling identity (auto-incrementing) on integer primary key using code first](https://stackoverflow.com/questions/7206273/disabling-identity-auto-incrementing-on-integer-primary-key-using-code-first) – Tim Feb 13 '20 at 16:18

0 Answers0