Seed database with test data using Entity Framework

Step 1: Right click on the project in solution explorer and add a class file with name = EmployeeDBContextSeeder.cs Step 2: Copy and paste the following code in EmployeeDBContextSeeder.cs file using System.Collections.Generic; using System.Data.Entity; namespace EntityFrameworkDemo { public class EmployeeDBContextSeeder : DropCreateDatabaseIfModelChanges { protected override void Seed(EmployeeDBContext context) { Department department1 = new Department() {… Continue reading Seed database with test data using Entity Framework

Advertisements