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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:55:03+00:00 2026-05-27T06:55:03+00:00

I have a misunderstanding somewhere with the Entity Framework. This code is from my

  • 0

I have a misunderstanding somewhere with the Entity Framework. This code is from my unit testing:

Public Sub UpdateRosterLinkTest()
    Dim target As PlayerAdmin = New PlayerAdmin()

    target.PlayerAdminManager = playerAdminTestManager
    target.Team = playerAdminTestManager.GetAirForceMensBB()

    playerAdminTestManager.resetRosterLink(target)
    Assert.IsNull(target.Team.RosterLink)

    Dim playerAdmin As PlayerAdmin = New PlayerAdmin()
    playerAdmin.TeamId = 12434
    playerAdmin.RosterLink = "Roster Link"

    playerAdmin.UpdateRosterLink()

    Dim team As DAL.Team = playerAdminTestManager.GetAirForceMensBB()
    Assert.AreEqual("Roster Link", team.RosterLink)

End Sub

I’m creating a PlayerAdmin, which is a model class. target.Team is an Entity object. What I do is reset the RosterLink field in the Team just to make sure our test starts out at the same place. Then I call the UpdateRosterLink() function. That looks like:

Function UpdateRosterLink() As Integer
        If (PlayerAdminManager Is Nothing) Then
            PlayerAdminManager = New PlayerAdminManager()
        End If

        Team = PlayerAdminManager.GetTeamByTeamId(TeamId)
        Team.RosterLink = RosterLink
        Dim numberOfChanges As Integer = PlayerAdminManager.SaveChanges()
        Return numberOfChanges
    End Function

When I run this code, I can see the changes saved to the SQL Server this pulls from (RosterLink = Roster Link, like I set in the unit test).

However, my unit test is failing, because team.RosterLink is still Nothing. The function GetAirForceMensBB() returns the Team with TeamId = 12434:

Function GetAirForceMensBB() As DAL.Team
    Return (From team In Container.Teams Where team.TeamId = 12434).SingleOrDefault
End Function

I’m sure I’m using the entity framework incorrectly and it probably has something to do with the fact that I am calling the PlayerAdminTestManager in different places, but I don’t understand why. Although, I set the PlayerAdminManager to be the PlayerAdminTestManager. PlayerAdminTestManager extends PlayerAdminManager, fyi.

Why is team.RosterLink not showing the update from UpdateRosterLink?

Thanks

EDIT
Container is my ObjectContext. This is how I access the information stored in the database. Container.Teams represents my Teams table.

  • 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-27T06:55:03+00:00Added an answer on May 27, 2026 at 6:55 am

    The problem was I was referencing different instantiations of the Container (each manager created its own). Thus, the entity items were not attached to anything.

    Doh!

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

Sidebar

Related Questions

I have the following code that shows either a bug or a misunderstanding on
this question can create a misunderstanding: I know I have to use CSS to
Have just started using Visual Studio Professional's built-in unit testing features, which as I
All the generated webservice-stubs from our backend have an equals-method similar to this one:
I learning ruby singletons and have misunderstanding with such code: class MyClass def self.class_singleton_mymethod
I seem to have misunderstanding here. I need to implement public/private key encryption (PKCS)
I have the following code from Codeigniter index.php My understanding is that, If /
I have a misunderstanding about zend non empty validation. I am using following code
I have a similar post on this on StackOverflow but perhaps my misunderstanding is
I have the following code shape. It seems that I'm misunderstanding the C# method

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.