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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T14:32:31+00:00 2026-05-27T14:32:31+00:00

Motivation : My EF4.1 DbContext is saving Entities in the wrong order Reason :

  • 0

Motivation : My EF4.1 DbContext is saving Entities in the wrong order

Reason : Lack of navigation properties on my models

How I want to fix it :

I want to set up foreign key relationships in my DbContext. The catch is that my entity objects have no navigation properties (I’m using it to populate a web service and then firing DTO objects over to my application).

The classes below would be an example. In MinorClass, I want to configure my context so that it knows MajorClassID is a foreign key. The articles I’ve been finding on the internet on how to explicitly define Foreign Keys involve using navigational properties, which my objects dont have.

Is there a way to map this relationship?

public class MinorClass
{
    public Guid ID {get;set:}
    public Guid MajorClassID {get;set;} // foreign key
    public string Name {get;set;}
}

public class MajorClass
{
    public Guid ID {get;set;}
    public string Name {get;set;}
}
  • 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-05-27T14:32:32+00:00Added an answer on May 27, 2026 at 2:32 pm

    Navigation property is primary construct whereas foreign key is helper (imho wrong helper). EF recognizes ordering of DB commands by relationships which are defined by navigation properties. You cannot define relation just by foreign key. You need navigation property on at least one side of the relation.

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

Sidebar

Related Questions

Motivation: I want to reduce the size of the page when is accessed, so
Having (presumably) understood the motivation behind Nuget, I want to know, whether we still
So here is my basic motivation for my question obfuscated a little: I want
My motivation for the augmentation of Object is I want to be able to
Motivation: reason why I'm considering it is that my genius project manager thinks that
I have two queries like so, $q = $dbc -> prepare(UPDATE accounts SET motivation
Motivation I'd like to find a way to take an arbitrary color and lighten
Motivation: I have fxcop integrated in the build process, which makes fxcopcmd.exe run each
Motivation Recently I searched for a way to initialize a complex object without passing
motivation: I would like to create a utility class so that instead of having

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.