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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T16:13:12+00:00 2026-06-09T16:13:12+00:00

An application persists Guid field in Mongo and it ends up being stored as

  • 0

An application persists Guid field in Mongo and it ends up being stored as BinData:

"_id" : new BinData(3, "WBAc3FDBDU+Zh/cBQFPc3Q==")

The advantage in this case is compactness, the disadvantage shows up when one needs to troubleshoot the application. Guids are passed via URLs, and constantly transforming them to BinData when going to Mongo console is a bit painful.

What are drawbacks of storing Guid as string in addition to increase in size? One advantage is ease of troubleshooting:

"_id" : "3c901cac-5b90-4a09-896c-00e4779a9199"

Here is a prototype of a persistent entity in C#:

class Thing
{
    [BsonIgnore]
    public Guid Id { get; set; }

    [BsonId]
    public string DontUseInAppMongoId
    {
        get { return Id.ToString(); }
        set { Id = Guid.Parse(value); }
    }
}
  • 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-09T16:13:14+00:00Added an answer on June 9, 2026 at 4:13 pm

    In addition to gregor’s answer, using Guids will currently prevent the use of the new Aggregation Framework as it is represented as a binary type. Regardless, you can do what you are wanting in an easier way. This will let the mongodb bson library handle doing the conversions for you.

    public class MyClass
    {
      [BsonRepresentation(BsonType.String)]
      public Guid Id { get; set;}
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to C#. I'm building an application that persists an XML file with
Is it possible to set a cookie in an iPhone Application that persists, so
We are trying to implement the Microsoft Sync Framework into our application that persists
Application : HTA (therefore IE) This is an application that uses SendKeys to populate
I'm debeloping a Java Swing application, which persists the information through Hibernate, currently using
I have a Java application that persists byte[] structures to a DB (using Hibernate).
In a dialog from my application, I have an observable collection (stored somewhere else)
I made a form in my PHP / jQuery Mobile web application with this
I want to create a web application with a model that persists between HTTP
I want a menu in my application that persists across pages. One way to

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.