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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T03:57:50+00:00 2026-06-13T03:57:50+00:00

The sample db that comes with RavenDB has Albums document collection, that each have

  • 0

The sample db that comes with RavenDB has Albums document collection, that each have a Genre embedded document in it, like this:

{
  ... other stuff...
  "Genre": {
    "Id": "genres/1",
    "Name": "Rock"
  },
  ... other stuff...
}

Notice that here the Genre has Id and Name fields.

But when you look at Genre documents, they have Id, Name, and Description fields, like this:

{
  "Description": "Rock and Roll is a form of rock music developed in the 1950s and 1960s. Rock music combines many kinds of music from the United States, such as country music, folk music, church music, work songs, blues and jazz.",
  "Name": "Rock"
}

How can I model in code so that when I Store() then SaveChanges() that the Genre will be serialized and saved differently (like the example data) when saving its own document versus when saving the Album document and embedding the Genre?

  • 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-13T03:57:52+00:00Added an answer on June 13, 2026 at 3:57 am

    This model will match the ravendb sample data:

    public class Genre
    {
        public string Id { get; set; }
        public string Description { get; set; }
        public string Name { get; set; }
    }
    
    public class Album
    {
        public string Id { get; set; }
        public string AlbumArtUrl { get; set; }
        public GenreRef Genre { get; set; }
        public decimal Price { get; set; }
        public string Title { get; set; }
        public int CountSold { get; set; }
        public ArtistRef Artist { get; set; }
    
        public class GenreRef
        {
            public string Id { get; set; }
            public string Name { get; set; }
        }
    
        public class ArtistRef
        {
            public string Id { get; set; }
            public string Name { get; set; }
        }
    }
    

    Example usage with includes:

    var albumId = "albums/1";
    var album = session.Include<Album>(x => x.Genre.Id)
                       .Load<Album>(albumId);
    var genre = session.Load<Genre>(album.Genre.Id);
    

    The include means that when loading the Genre, there is no db call because it’s already tracked in the session.

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

Sidebar

Related Questions

I have written this event photography application that features a slideshow among other things.
I did one sample application using WebView, in that web view the URL comes
I have the following code sample that im trying to wrap my head around
I am trying to run the native activity sample that comes with the Android
I am trying to deploy the sample-app war file that comes with PushSDK.But was
I have a primarly code based iphone sample app that works. It is Navigation
Let me preface this by saying that I know the ContactCenter sample is just
The sample program that comes with the Extension Library works just fine, but when
Put simply, I have a WCF service that manages apples. Apart from other functionality,
This is driving me nuts. Here is some HTML and CSS that I have

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.