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 5935019
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T15:11:42+00:00 2026-05-22T15:11:42+00:00

I want to create the app modular and would like to create multiple EDMX,

  • 0

I want to create the app modular and would like to create multiple EDMX, with just the subset to tables needed in that specific context.

E.g.

  • an EDMX for Invoics: Invoice table, InvoiceDetails, Customer
  • an EDMX for Orders: Order table, OrderDetails, Customer
  • etc.

This way I keep things smaller and manageable (I think)

But I might need to create a generic module that performs a batch operation on several entities, possible spread across multiple EDMX. E.g. Consolidate clients – merge multiple clients to a single client (maybe users entered same client by mistake multiple times, or I want to merge two client accounts,etc)

For this I want to use ServiceLocator pattern

  1. define an interface, IClientMerger
  2. and as I create a new entity that refer to client, I also create a new IClientMerger handler
  3. when I need to deduplicate, I load all ICLientHandlers, and call them in a loop, and they replace the old ClientID with new ClientID in handled entity (one in Invoices, one in Orders, etc.)

All is fine, but I want to pack this all in a transaction, so all will get saved or not. being in separate EDMX, how can I pack them all in a single transaction? Should I manually create a ADO.NET transaction and call objectContext.SaveChanges for all EDMX inside? Or there’s another, more elegant way?

Thanks

  • 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-22T15:11:42+00:00Added an answer on May 22, 2026 at 3:11 pm
    using(TransactionScope tran = new TransactionScope())
    {
      //do some work...
      context1.SaveChanges()
      context2.SaveChanges()
    
      tran.Commit()
    }
    

    If there’s no Commit before the TransactionScope is disposed, the transaction is automatically rollbacked.

    The contexts can even work on differents sql servers if MS DTC is available.

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

Sidebar

Related Questions

I want to create a modular(plugin-like) application that uses JPA as its persistence abstraction,
In my SQL Server backend for my app, I want to create history tables
I want to create an app that has pictures Ive taken or created and
I want to create an app that contains a Service S and an Activity
If I want to create .NET app that needs database functionalities, but I do
Goal I want to create a web app with a horizontal GUI bar that
I want to create an app which would monitor changes to data in a
Hey everybody, I want to create an app that handles some sort of recognition
I want to do something like this: create table app_users ( app_user_id smallint(6) not
I want to create a trace on a database server from my C# app,

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.