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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T17:11:56+00:00 2026-06-12T17:11:56+00:00

MongoDB has its own ObjectId type that it uses as the default primary key.

  • 0

MongoDB has its own ObjectId type that it uses as the default primary key. I’m trying to set up an application designed using Onion Architecture with MongoDB as the persistence engine in the infrastructure layer. If my POCO classes are defined in my domain layer but use MongoDB’s ObjectID type for primary keys, will that force me to add MongoDB as a dependency on my domain layer?

  • 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-12T17:11:57+00:00Added an answer on June 12, 2026 at 5:11 pm

    You should not need a reference to MongoDB anywhere except the outer-most layer. In onion architecture, data persistence is considered infrastructure. I would have MongoDB be part of a repository implementation that implements repository interfaces defined in the domain model.

    MongoDB documents have an _id field that uniquely identifies it. See here:

    The _id value may be of any type, other than arrays, so long as it is a unique. If your document has a natural primary key that is immutable we recommend you use that in _id instead of the automatically generated ids.

    Don’t let your persistence mechanism push you around!

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

Sidebar

Related Questions

I have a hosted web application that has MongoDB as its DB. Now, I
I have a collection of articles in MongoDB that has the following structure: {
I have an object that has an instance of Doctrine\ODM\MongoDB\Query\Builder . When I serialize
My rails app has its own MySql database (and requires the mysql2 gem) but
I'm trying to let MongoDB detect a duplicate value based on its index. I
I am building a little app that has to communicate with a MongoDB database.
MongoDB has support for atomic updates. I.e. I can be sure that when a
Using MongoDB C# driver ( http://github.com/samus/mongodb-csharp ), seems that I'm unable to get the
In mongodb you can set the log level to between 0 and 5. I
I'm writing a basic event registration web application and I'm wondering whether MongoDB would

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.