Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3991730
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T06:39:03+00:00 2026-05-20T06:39:03+00:00

Does Entity Framework use a transaction for when you call SaveChanges on your context?

  • 0

Does Entity Framework use a transaction for when you call SaveChanges on your context? Is there any way to turn off transactions completely, or have a certain entity opt out of a transaction?

AdventureWorksEntities db = new AdventureWorksEntities();

Product p1 = new Product();
// ...

Product p2 = new Product();
// set invalid data

db.Products.AddObject(p1);
db.Products.AddObject(p2);

// what happens when I call this - does it roll back everything?
// can i tell p2 not to participate in the transaction?
db.SaveChanges();
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T06:39:04+00:00Added an answer on May 20, 2026 at 6:39 am

    Yes, EF4 will create a new transaction if one does not already exist. See

    http://msdn.microsoft.com/en-us/library/bb896325.aspx

    When you call SaveChanges, if a
    current transaction exists, the Entity
    Framework uses this transaction for
    operations against the data source.
    Otherwise, it creates a new
    transaction for the operation. You can
    define transactions by using
    EntityTransaction, Transaction, or
    TransactionScope.

    No, there is no way to exempt a single entity from the transaction.

    Not sure about your third question – about whether you can turn off transactions completely, but I’m guessing not based on the above excerpt.

    I know this isn’t the answer you wanted to hear, but if you want P2 to save regardless of whether P1 succeeds, you would need to save P2 into a different object context.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does anyone know of any good tutorials on ADO.NET Entity Framework? There are a
Does anyone know whether there's a way to mock Entity Data Provider so Unit
Does Entity Framework innately support any sort of change tracking in terms of detecting
Dumb question I'm sure, but why does Entity Framework EntityDataSource object require the where
When using the Entity Framework, does ESQL perform better than Linq to Entities? I'd
In what instances does Entity Framework automatically load child rows and other related rows
I have an entity framework data context and a SQL command that both need
This question, asked a year ago, is similar: Does the Entity Framework 4 support
I use auto generated Entity-Framework Data Model for a Database that has 100+ tables.
I have a class library that I use to hold the Entity Framework Data

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.