private static void AddTestData(EFCContext context) { var clients = new[] { new CLIENT { CLIENT_ID = "CL99", CLIENT_NAME = "Client 99" }, //new CLIENT {CLIENT_ID ="CL80", CLIENT_NAME ="Client 80"} }; var clientContacts = new[] { new CLIENT_CONTACT { CLIENT_ID = "CL99", CONTACT_ID = 1, CONTACT_NAME = "Contact 1", CONTACT_EMAIL = "*****@*****.**" }, new CLIENT_CONTACT { CLIENT_ID = "CL99", CONTACT_ID = 2, CONTACT_NAME = "Contact 2", CONTACT_EMAIL = "*****@*****.**" }, new CLIENT_CONTACT { CLIENT_ID = "CL99", CONTACT_ID = 3, CONTACT_NAME = "Contact 3", CONTACT_EMAIL = "*****@*****.**" }, new CLIENT_CONTACT { CLIENT_ID = "CL99", CONTACT_ID = 4, CONTACT_NAME = "Contact 4", CONTACT_EMAIL = "*****@*****.**" }, }; var orders = new[] { new ORDER { ORDER_ID = 1, CLIENT_ID = "CL99", CREATION_DATE = DateTime.Now.Subtract(TimeSpan.FromDays(10)) }, new ORDER { ORDER_ID = 2, CLIENT_ID = "CL99", CREATION_DATE = DateTime.Now.Subtract(TimeSpan.FromDays(5)) }, new ORDER { ORDER_ID = 3, CLIENT_ID = "CL99", CREATION_DATE = DateTime.Now.Subtract(TimeSpan.FromDays(2)) }, new ORDER { ORDER_ID = 4, CLIENT_ID = "CL99", CREATION_DATE = DateTime.Now }, }; var orderDetails = new[] { new ORDER_DETAIL { ORDER_ID = 1, CLIENT_ID = null, BILLING_TYPE = "B0" }, //no contact information new ORDER_DETAIL { ORDER_ID = 2, CLIENT_ID = "CL99", BILLING_CONTACT_ID = 1, SHIPPING_CONTACT_ID = 2, BILLING_TYPE = "B0" }, // Both contacts set new ORDER_DETAIL { ORDER_ID = 3, CLIENT_ID = "CL99", SHIPPING_CONTACT_ID = 3, BILLING_TYPE = "B1" }, //only Shipping contact new ORDER_DETAIL { ORDER_ID = 4, CLIENT_ID = "CL99", BILLING_CONTACT_ID = 4, BILLING_TYPE = "B3" }, //only billing contact }; try { context.AddRange(clients); context.AddRange(clientContacts); context.AddRange(orders); context.AddRange(orderDetails); var result = context.SaveChanges(); Console.WriteLine($"Test data added to {context.Database.ProviderName}, result => {result}"); } catch (Exception ex) { Console.WriteLine($"Failed {nameof(AddTestData)} {ex}"); } }