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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T00:09:55+00:00 2026-06-11T00:09:55+00:00

In an app on which I’m currently working, I just replaced db4o with RavenDB.

  • 0

In an app on which I’m currently working, I just replaced db4o with RavenDB. I just noticed something that wasn’t working, did some research, and now I need a sanity check.

Let’s assume this domain model:

Person has Name, Address, and Car properties.

Car has Make, Model, and Mileage properties.

With RavenDB, I can create a Car and save it. Then I can create a Person and assign a Car to the Person’s Car property. When I save Person, Car gets saved within Person. All seems fine.

The problem is when I later update Car.Mileage. Car gets updated in RavenDB, but not within Person.Car. Person.Car has the old mileage.

Car exists on its own. Person Joe can own the car, and so can Person Nancy. Both Person objects will have a reference to Car.

In RavenDB, how should this be handled? From everything I’ve read about aggregate/root objects, it looks like maybe I should add a CarId property to Person. Then, when I load Person, also manually load the Car by the ID. Is that right? Or can I embed the Car property within Person, and somehow have all Person objects show the correct Person.Car.Mileage as Car.Mileage changes over time?

  • 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-11T00:09:57+00:00Added an answer on June 11, 2026 at 12:09 am

    If I understood your model correctly, you are generating 2 documents like this:

    {// cars/1
      "Make": "Honda",
      "Model": "Civic",
      "Mileage": 250000
    }
    

    And like this:

    {// persons/1
      "Name": "John Doe",
      "Address": "...",
      "Car": {
        "Id": "cars/1",
        "Make": "Honda",
        "Model": "Civic",
        "Mileage": 250000
      }
    }
    

    It’s important that in this document model. All of the car properties have been denormalized in the Person.Car property. So in your code, when you make an update to Car.Mileage and save it. You end up with the 2 document looking like this:

    {// cars/1
      "Make": "Honda",
      "Model": "Civic",
      "Mileage": 999999
    }
    

    And like this:

    {// persons/1
      "Name": "John Doe",
      "Address": "...",
      "Car": {
        "Id": "cars/1",
        "Make": "Honda",
        "Model": "Civic",
        "Mileage": 250000
      }
    }
    

    Which is exactly what you told Raven to do. With this document model, to make sure both documents are consistent you would need to update both the Car object like you did and the Person.Car.Mileage property for all the persons using that car.

    Depending on the data access needs you can modify your model in a few different ways. One option is to make your model look like this:

    {// cars/1
      "Make": "Honda",
      "Model": "Civic",
      "Mileage": 250000
    }
    

    And like this:

    {// persons/1
      "Name": "John Doe",
      "Address": "...",
      "Car": "cars/1"
    }
    

    With this document model you will only need to update the Car.Mileage property. If you select this option you can also get the referenced document back from Raven in a single network request. By doing something like this:

    var person = session.Include<Person>(x => x.Car).Load("persons/1");
    var car = session.Load<Car>(person.Car);
    

    But this is only one option in how you can change your document model to address your application’s needs.

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

Sidebar

Related Questions

I have an app which has a map and some POI on it. I'm
I have an app which contain some images in res/drawable/ and shows them in
I want to develop app which will recognize object(like monument or something) present in
I am developing an app which has some text inputs, and I want to
I am writing an app which will remove some Registry keys recursively using API
I'm making an app which uses push notifications, and I know that I need
I'm making an app which uses internet. I remember there was something developers had
I just mad a app which uses phongeab + phonegab BarcodeScanner Plugin. But for
I have an app which pings IP or IP range. The problem is that
I have an app which is closing after some period of time. The 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.