using System.Collections.Generic;
using System.Data.Entity;
using Z.EntityFramework.Plus;
public static void Main()
using (var context = new EntityContext())
var query = context.Customers.IncludeFilter(x => x.Invoice);
FiddleHelper.WriteTable("Invoice", query.ToList().Select( x => x.Invoice));
public static void GenerateData()
List<Customer> list = new List<Customer>() {
new Customer() { Invoice = new Invoice() { Description = "Invoice_A"}}
using (var context = new EntityContext())
context.BulkInsert(list, options => options.IncludeGraph = true);
public class EntityContext : DbContext
public EntityContext() : base(FiddleHelper.GetConnectionStringSqlServer())
public DbSet<Invoice> Invoices { get; set; }
public DbSet<Customer> Customers { get; set; }
public int CustomerID { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public Invoice Invoice { get; set; }
public int InvoiceID { get; set; }
public string Description { get; set; }