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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T22:42:21+00:00 2026-05-16T22:42:21+00:00

I’ve just started foraying into EF, and I’m trying to get my head around

  • 0

I’ve just started foraying into EF, and I’m trying to get my head around it (Generally easy enough). However for some reason it’s not actually saving the results, though it appears to be maybe cacheing the values for a time, and then rolling back to the previous values?

using (IAPlayerEntities IAPE = new IAPlayerEntities()) {
                ObjectSet<Player> Players = IAPE.Players;
                if (Players.Count() > 0) {
                    Player currentPlayer = new Player();
                    bool LoggedIn = false;
                    Players.DefaultIfEmpty(null);
                    while (!LoggedIn) {
                        Console.WriteLine("Please enter your Username:");
                        string username = Console.ReadLine();
                        Console.WriteLine("Please enter your Password:");
                        string password = MaskLine();
                        currentPlayer = Players.FirstOrDefault(r => r.Password == password && r.Name == username);
                        LoggedIn = (currentPlayer != null);
                        if (!LoggedIn) {
                            Console.WriteLine("{0}Invalid combination, please try again.", Environment.NewLine);
                        }
                    }
                    Console.WriteLine("{0}Please choose your colony.", Environment.NewLine);
                    foreach (Colony col in currentPlayer.Colonies) {
                        Console.WriteLine(@"{0}{1}:{0}{2}{0}Level {3}", Environment.NewLine, col.ID, col.Name, col.Level);
                    }
                    Console.WriteLine();
                    int colID = -1;
                    string colStr = Console.ReadLine();
                    while (!int.TryParse(colStr, out colID) || !currentPlayer.Colonies.Any(e => e.ID == colID)) {
                        if (colStr.ToLower() == "q") {
                            Console.WriteLine("Goodbye!");
                            return;
                        }
                        Console.WriteLine("{0}Invalid Colony. Please try again.", Environment.NewLine);
                        colStr = Console.ReadLine();
                    }
                    Console.WriteLine("Please enter a new name for the colony:");
                    string colName = Console.ReadLine();
                    bool b = IAPE.ObjectStateManager.GetObjectStateEntries(EntityState.Added | EntityState.Deleted | EntityState.Modified).Any();
                    currentPlayer.Colonies.First(e => e.ID == colID).Name = colName;
                    int change = IAPE.SaveChanges();
                    if (change >= 1) {
                        Console.WriteLine("{0}Colony has been renamed.", Environment.NewLine);
                    } else {
                        Console.WriteLine("{0}Colony could not be renamed.", Environment.NewLine);
                    }
                } else {
                    Console.WriteLine("No Registered users");
                }
            }

Ignore the über secure login, it’s only in there to get a player entity from it for testing.

the bool b is set to true before the save, and then if I use the debugger to run the same line in the “Immediate Window” pane then it shows false. Which to me, means it saved? And If I re-run the application after it’s closed then the changed value is in place. But eventually it will return to the previous value, and if I check the database straight after it still shows the original name, so I’m not quite sure what’s going on here?

It’s running on VCS2010, so Framework 4.

Thanks, Psy

  • 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-16T22:42:21+00:00Added an answer on May 16, 2026 at 10:42 pm

    Checked the SQL going over to the database, and it’s fine, after some investigation, turned out that I had a copy of the database within the project, which was over-riding the one in the output everytime I rebuilt it.

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

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
link Im having trouble converting the html entites into html characters, (&# 8217;) i
this is what i have right now Drawing an RSS feed into the php,
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I am trying to loop through a bunch of documents I have to put
I have some data like this: 1 2 3 4 5 9 2 6
I've got a string that has curly quotes in it. I'd like to replace
I want use html5's new tag to play a wav file (currently only supported
I have a JSP page retrieving data and when single or double quotes are

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.