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

  • SEARCH
  • Home
  • 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 6579495
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:54:18+00:00 2026-05-25T15:54:18+00:00

i have multiple repositories in my project for different entities and each has it’s

  • 0

i have multiple repositories in my project for different entities and each has it’s own datacontext (which comes from a base class for my repositories).

In my service layer, there are many times that the business logic requires me to add/edit objects in multiple repositories (hence inturn using different DataContext).

So when i end up doing .SaveContext on multiple repositories. Which seems like a bad thing to do as ideally i should be able to hit Save on one context and one ado.net call to the DB should perform all the tasks.

What am i doing wrong here?

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-25T15:54:19+00:00Added an answer on May 25, 2026 at 3:54 pm

    You need to look at using the Unit of Work pattern with your repositories, as it allows your multiple repositories to take part in a single logical transaction.

    there are plenty of blog posts around the net about how to do this, including;

    • Using Repository and Unit of Work patterns with Entity Framework 4.0
    • ASP.NET MVC, DataContext and The Unit of Work Pattern
    • The Unit Of Work Pattern And Persistence Ignorance

    Also here is a good tutorial walking through using MVC and EF with a Unit of Work + Repository pattern.

    As here is a nice diagram explaining how it works;

    enter image description here

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

Sidebar

Related Questions

I have multiple svn code repositories. How do I specify which repository I would
Is it possible to have multiple repositories for the same project? I am currently
I have multiple different closed source projects based on a similar code base and
I'm converting a big SVN repository into multiple git repositories (one for each project).
Two questions actually 1) Have anyone accomplished setting up multiple repositories in a project
Currently I have project consisting of multiple repositories, e.g.: +--- Project (main repo) +---
I have multiple git repositories to have some interdependencies between them. I need to
I have multiple projects which are to be hosted together in a Tomcat container,
In CVS we have on project with multiple directories in there. There is a
I have several applications across sub domains on various servers. Each application has its

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.