string[] usersToAdd = new string[] { "asd", "asdert", "gasdff6" };
using (Entities context = new Entities())
{
foreach (string user in usersToAdd)
{
context.AddToUsers(new User { Name = user });
}
try
{
context.SaveChanges(); //Exception thrown: user 'gasdff6' already exist.
}
catch (Exception e)
{
//Roll back all changes including the two previous users.
}
या शायद यह स्वचालित रूप से किया जाता है, जिसका अर्थ है कि अगर त्रुटि होती है, तो सभी परिवर्तनों के लिए परिवर्तन करना रद्द कर दिया जाता है। है ना?एंटिटी फ्रेमवर्क
हाँ यह सही है –