If I have a dataset and add 2 rows to one table, 3 rows to another table and update another 2 tables what ensures that when I update/accept changes to the database the updates are carried out in the corredt order ?

e.g

I have 2 products which are have foreign keys to the Company table. The foreign keys are currently null.

I add a customer record then update the products table to point to this table.

How does ado.net know that the Company table needs to be inserted first.

NOTE. - I am generating my own unique keys and not using autonum.