2

is there any option how to generate data insert script in EF from model? For example: I have a tables(objects) structure like: People->Customers->Orders...

I want to load one instance of the People recursively....People people = peopleRepository.GetByKey(1) and from this people instance I want to generate insert script for all child objects like:

insert into people(id, name, ...) values (1, john...)
insert into customers(id, peopleid) values(1, 1)
insert into orders(id, customerid) values (1, 1)
insert into orders(id, customerid) values (1, 2)...

is this possible in EF?

thanks

Ladislav Mrnka
  • 360,892
  • 59
  • 660
  • 670
zosim
  • 2,959
  • 6
  • 31
  • 34

1 Answers1

0

No there is not any such tool. You must write it yourselves. Simply call

var person = context.People.Include("Customers.Orders").Where(p => p.Id == 1);

and use data to create insert scripts.

Ladislav Mrnka
  • 360,892
  • 59
  • 660
  • 670