using Microsoft.EntityFrameworkCore;
using System.Collections.Generic;
using Microsoft.Data.SqlClient;
public static void Main()
using (var context = new EntityContext())
context.Database.EnsureCreated();
using (var context = new EntityContext())
context.Customers.Add(new Customer() { Code = $"Info", Name = "Support Team", Email = "info@zzzprojects.com" });
context.Customers.Add(new Customer() { Code = $"Sales", Name = "Sales Team", Email = "sales@zzzprojects.com" });
context.BulkSaveChanges();
FiddleHelper.WriteTable("1 - Customers", context.Customers.ToList());
using (var context = new EntityContext())
var customers = context.Customers.ToList();
customers.ForEach(x => x.Name = "Best " + x.Name);
context.BulkSaveChanges(options => options.BatchSize = 1000);
FiddleHelper.WriteTable("2 - Customers (Updated)", context.Customers.Take(5).ToList());
public class EntityContext : DbContext
public DbSet<Customer> Customers { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
optionsBuilder.UseSqlServer(new SqlConnection(FiddleHelper.GetConnectionStringSqlServer()));
base.OnConfiguring(optionsBuilder);
public int CustomerID { get; set; }
public string Code { get; set; }
public string Name { get; set; }
public string Email { get; set; }