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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:17:35+00:00 2026-05-26T17:17:35+00:00

I have a Database Entity Model within my ASP.Net Project There are two foreignkeyconstructs,

  • 0

I have a Database Entity Model within my ASP.Net Project

Model.edmx construct

There are two foreignkeyconstructs, both are constructs between the id’s in the shown relation.

Now I’m trying to add 100 sample entries with the following method

            IntraNetEntities entities = new IntraNetEntities();

        if (entities.EmployeeList.Count() == 0)
        {
            using (entities)
            {
                for (int i = 0; i < 100; i++)
                {     

                    EmployeeList newEmployeeList = new EmployeeList()
                    {
                        department = "Standardabteilung",
                        mobile = i,
                        landline = 1 + i,
                        mail = "Standardemail",
                        position = "Standardfunktion",
                        shortcode = "abc",
                        lastname = "StandardNachname",
                        roomnumber = Convert.ToDouble(i),
                        firstname = "Standardvorname"
                    };

                    PrivateContact newPrivateContact = new PrivateContact()
                    {
                            city = "Standardstadt",
                            country = "deutscheland",
                            landline = i,
                            mail = "standardemail",
                            mobile = i * 2,
                            street = "standardstreet",
                            zip = i * 10,
                            EmployeeList = newEmployeeList
                    };

                    WorkContact newWorkContact = new WorkContact()
                    {
                        city = "Standardstadt",
                        country = "deutscheland",
                        landline = i * 9,
                        mobile = i * 12 / 8,
                        mail = "standardmail",
                        street = "standardstraße",
                        zip = i * 9,
                        EmployeeList = newEmployeeList
                    };

                    newEmployeeList.PrivateContact = newPrivateContact;
                    newEmployeeList.WorkContact = newWorkContact;

                    entities.AddToEmployeeList(newEmployeeList);
                    entities.AddToPrivateContact(newPrivateContact);
                    entities.AddToWorkContact(newWorkContact);

                }

                entities.saveChanges();

                return true;
            }
        }
        else
        {
            return false;
        }

My problem is, that my Navigation Properties disappear when this method ends!
They all look fine in debugging while still being in the using case but afterwards they are all null without me doing any changes to those values.

How can I keep the navigation values?

Thanks

  • 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-26T17:17:36+00:00Added an answer on May 26, 2026 at 5:17 pm

    Using calls “Dispose” at the end of it. That’s why your navigation properties drop off. From the MSDN website:

    The using statement calls the Dispose method on the object in the correct way, and (when you use it as shown earlier) it also causes the object itself to go out of scope as soon as Dispose is called.

    http://msdn.microsoft.com/en-us/library/yh598w02.aspx

    The using statement allows the programmer to specify when objects that use resources should release them.

    http://msdn.microsoft.com/en-us/library/yh598w02%28v=vs.80%29.aspx

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

Sidebar

Related Questions

I have my Database , that have my ADO.NET Entity Data Model that have
I'm working on a project in which we have a database, data layer (entity
I have two tables in my database schema that represent an entity having a
Now that I have built a database. Visual Studio 2008 SP1’s ADO.NET Entity Framework
General Info: ASP.NET MVC app using ADO.NET Entity Framework SQL Server 2005 I have
I have generated entity model from my database which created entity classes. 1) Is
Scenario I am playing MVC NerdDinner project and using ado.net entity data model instead
I have two tables in my database - Category and Department which both contain
I have a many-to-many structure in place in my database / Entity Framework model.
I'm playing around with WCF Data Services (ADO.NET Data Services). I have an entity

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.