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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T21:20:56+00:00 2026-06-04T21:20:56+00:00

Our ASP.NET MVC project uses MS SQL Server (for most of the data) and

  • 0

Our ASP.NET MVC project uses MS SQL Server (for most of the data) and MongoDB (least important stuff like audit logs, internal messaging system, notifications etc.) at the same time.
So the question is what should data access layer architecture look like in my case? We are using Entity Framework POCO generator to access SQL Server as unit testing is important and ideally I would prefer to extend an IEntities interface generated by Entity Framework so that business logic and UI developers won’t even know where the actual object is stored:

[GeneratedCode("Entity","0.9")]
public partial interface IEntities
{
    IObjectSet<Administrator> Administrators { get; }
    IObjectSet<User> Users { get; }
    IObjectSet<Banner> Banners { get; }
    IObjectSet<AuditLog> AuditLogs { get; }

    ...
}

In this example only AuditLog entities are stored in the MongoDB while the rest of them work through SQL Server.

The best solution I have so far is to implement an IObjectSet<T> interface on top of the MongoDB C# driver with MongoRepository (http://mongorepository.codeplex.com/) project being a half ready solution for my problem. Does anyone know a better approach?

  • 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-06-04T21:21:00+00:00Added an answer on June 4, 2026 at 9:21 pm

    The problem with MongoRepository is that your entities must derive from its Entity base class or implements IEntity in every POCO. I’m working on a solo project that I’ve named “MongoDB.Dynamic” that will be compatible with POCO entity framework classes. With MongoDB.Dynamic will allow you to use just interfaces to persist data.

    [TestInitialize]
    public void Initialize()
    {
        Dynamic.Config.SetKeyName<ICustomer>(c => c.Id);
        Dynamic.Config.SetKeyName<IOrder>(o => o.Id);
        Dynamic.Config.LoadCollection<ICustomer, IOrder>(customer => customer.Orders, order => order.IdCustomer);
        Dynamic.Config.LoadFK<IOrder, ICustomer>(order => order.Customer, order => order.IdCustomer);
        var customers = Dynamic.GetCollection<ICustomer>();
        var orders = Dynamic.GetCollection<IOrder>();
        customers.RemoveAll(true);
        orders.RemoveAll(true);
    }
    
    [TestMethod]
    public void TestLoadOrderByCustomerAuto()
    {
        var customers = Dynamic.GetCollection<ICustomer>();
        var orders = Dynamic.GetCollection<IOrder>();
    
        var cust = customers.New();
        cust.Name = "X";
        customers.Upsert(cust);
    
        var check = customers.GetFirstOrDefault();
    
        var o1 = orders.New();
        o1.IdCustomer = check.Id;
        orders.Upsert(o1);
    
        var o2 = orders.New();
        o2.IdCustomer = check.Id;
        orders.Upsert(o2);
    
        var verify = customers.GetFirstOrDefault();
    
        Assert.IsNotNull(verify.Orders);
        Assert.IsTrue(verify.Orders.Count() == 2);
    }
    

    In a couple of days I’ll publish this project. Can’t wait to share with community.

    EDIT: The interfaces referenced by code above:

    public interface ICustomer
    {
        int Id { get; set; }
        string Name { get; set; }
    
        IEnumerable<IOrder> Orders { get; set; }
    }
    
    public interface IOrder
    {
        int Id { get; set; }
        int IdCustomer { get; set; }
    
        ICustomer Customer { get; set; }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using T4MVC in our ASP.NET MVC project. I have a statement like
I have an ASP.NET MVC project that I would like to unit test. Most
After pushing my asp.net mvc (with spark view engine) project to our live server
In our ASP.NET MVC project we have a Strings.resx file and the accompanying autogenerated
Using log4net we would like to log all calls to our ASP.NET MVC controller
We found a problem while accessing the Web service from our ASP.Net MVC project
Our current project is written in ASP.NET MVC 1 using mvc-turbines (and unity) for
Right now our team's ASP.NET MVC 2.0 web project takes about 4 minutes to
We are trying to write Unit Tests in our ASP.Net MVC project. Some of
We have a ASP.Net MVC project that runs fine on our developer machines. When

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.