entity framework - How to store information edited or created in more than 1 entities -


In my ASP.NET MVC application, I want to store information in many different organizations, which are edited or made Persons, know, ..).

Then there are input fields for each attribute in the table of persons and the address table in my visual view. Now I want to accumulate values ​​in both institutions at the same time? Is It Recovering Using a View Modal? Or is there a better way?

You can actually type a visual model which encapsulates all the entties you need for that view , But when it's time to store them in the database, you still have to do every institution individually, for example you have:

  // Here you are already Have caught their institutions; // We are in your verb // it is your reference, but please use // dependency injection in your controller ^ _ ^ var context = new dbContext (); Context.Add (person); Context.Add (address); // It will store all the instances you have added at one time context.SaveChanges ();   

SaveChanges () works as well when you update entities, unless you have told the same context through the institutions Retrieve.

Comments