protected override void OnModelCreating(DbModelBuilder modelBuilder) { modelBuilder.Entity<PostBody>().Property(p => p.ID) .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None); } 也可以通过在实体类属性上加标记实现: public class BlogPost { [DatabaseGenerated(DatabaseGeneratedOption.None)] public int ID { get; set; } }