using System.Collections.Generic;
using System.Data.Entity;
using System.Linq.Dynamic.Core;
public static void Main()
using (var context = new EntityContext())
var list = context.Customers
.Include(c => c.Location)
.Where(c => c.Location != null ? c.Location.Name == "test" : false)
FiddleHelper.WriteTable(list);
public static void GenerateData()
var list = new List<Customer>();
Name = "Terri Lee Duffy",
Location = new Location() { Name = "test" },
Name = "Michael Sullivan",
Name = "Rebecca Bradley",
Location = new Location() { Name = "test" },
using (var context = new EntityContext())
context.Customers.AddRange(list);
context.BulkSaveChanges();
public class EntityContext : DbContext
public EntityContext() : base(FiddleHelper.GetConnectionStringSqlServer())
public DbSet<Customer> Customers { get; set; }
public DbSet<Location> Locations { get; set; }
public int CustomerID { get; set; }
public string Name { get; set; }
public string CompanyName { get; set; }
public string City { get; set; }
public string Phone { get; set; }
public Location Location { get; set; }
public int LocationID { get; set; }
public string Name { get; set; }