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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T23:47:11+00:00 2026-06-02T23:47:11+00:00

[Everything stripped down to highlight the problem] SchemeRequest —————————— Id SchemeId [FK to Schemes

  • 0

[Everything stripped down to highlight the problem]

SchemeRequest
------------------------------
Id
SchemeId [FK to Schemes Table]
------------------------------

using(var scope = new TransactionScope())
{
    var request = new SchemeRequest { SchemeId = [schemeId] };
    this.dbContext.SchemeRequests.Add(request);
    this.dbContext.SaveChanges();

    this.mailer.SendMail(request); // request.Scheme is null when it should not be

    scope.Complete();
}

I am using EF Model first. Now after the call to SaveChanges the Navigation property Scheme in SchemeRequest is null. I am not sure why. Can anyone help? There is another navigation property which seems to work fine. How do I debug this ie how do I find out whats happening behind the scenes.?

I checked and doublechecked the relationships, properties etc but everything seems to be ok.

  • 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-02T23:47:13+00:00Added an answer on June 2, 2026 at 11:47 pm

    It’s not expected that the navigation property is loaded. You only save a new entitiy without setting its navigation property. EF does not load another entity automatically when you save the parent.

    However, the navigation property would be set in two situations:

    • The Scheme with the SchemeId you set in the new SchemeRequest is already loaded and attached to the context. EF would fix the relationship automatically and set the navigation property.

    • If you use lazy loading the navigation property would be loaded after setting the SchemeId as soon as you access it. However, you need to create the new SchemeRequest as a lazy loading proxy instead of using new:

      var request = this.dbContext.SchemeRequests.Create();
      request.SchemeId = schemeId;
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple cpp file which uses GIO. I have stripped out everything
Everything is fine and the final problem is so annoying. Compile is great but
OK here is stripped down version of what I have in my app Artist
I have following JS code (stripped to minimal size where problem still exists) <html>
I want Lucene.NET to store a value while indexing a modified, stripped-down version of
I stripped this down to the bare essentials: <!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0
Below is a stripped down model and associated method. I am looking for a
I'm using knockout (awesome library), but I've run into a problem with templates: the
i'm looking for a stripped down version of Twitter's Bootstrap for my website the
Everything was working just fine and on the last publish my wordpress directory is

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.