using System.Data.Entity;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
public static void Main()
List<Customer> list = new List<Customer>()
new Customer() { CustomerID = 1, IdentityInt = 3, Name ="Customer_A" },
new Customer() { CustomerID = 2, IdentityInt = 2, Name ="Customer_B" },
new Customer() { CustomerID = 3, IdentityInt = 4, Name ="Customer_C" }
using (var context = new EntityContext())
context.BulkInsert(list, options => options.InsertKeepIdentity = true);
using (var context = new EntityContext())
FiddleHelper.WriteTable(context.Customers.ToList());
public class EntityContext : DbContext
public EntityContext() : base(FiddleHelper.GetConnectionStringSqlServer())
public DbSet<Customer> Customers { get; set; }
public int CustomerID { get; set; }
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int IdentityInt { get; set; }
public string Name { get; set; }