title: What could be causing db.SubmitChanges() to not work in linq-to-sql?
body: <p>I've set up a very simple example with LINQ-TO-SQL in WPF.</p>
  
  <p>I can get an <strong>object</strong> (pageItem) out like this and I can change the <strong>property</strong> and when I call <strong>SubmitChanges</strong>() it gives me <strong>no error</strong> but it <strong>doesn't save</strong> the change.</p>
  
  <pre><code>MainDataContext db = new MainDataContext();
  var pageItem = (from p in db.PageItems
                where p.Id == 1
                select p).SingleOrDefault();
  
  pageItem.Title = "changed";
  db.SubmitChanges();
  </code></pre>
  
  <p><strong>What could be causing SubmitChanges not to submit the changes?</strong></p>
  
  <p><H1>MORE INFO:</H1></p>
  
  <p>This doesn't work either, even the db.ExecuteCommand doesn't work, and strangely when debugging F11 doesn't step into SubmitChanges() or ExecuteCommand(), why can't I step in those?</p>
  
  <pre><code>using (var db = new MainDataContext())
  {
      var pageItem = (from p in db.PageItems
                      where p.Id == 1
                      select p).SingleOrDefault();
  
      pageItem.Title = "changed";
      db.SubmitChanges();
  
      db.ExecuteCommand("INSERT INTO PageItems (Title) VALUES ('this is the title')");
  
  
      if (pageItem != null)
          MainContent.Children.Add(new QuickForm(pageItem));
  
  }
  </code></pre>
  
  <h1>more info:</h1>
  
  <p>The db.Log = Console.Out gives me this:</p>
  
  <pre><code>SELECT [t0].[Id], [t0].[IdCode], [t0].[Title], [t0].[Description], [t0].[DisplayOrder]
  FROM [dbo].[PageItems] AS [t0]
  WHERE [t0].[Id] = @p0
  'TestPageManager23434.vshost.exe' (Managed): Loaded 'C:\Windows\assembly\GAC_MSIL\PresentationFramework.resources\3.0.0.0_de_31bf3856ad364e35\PresentationFramework.resources.dll'
  -- @p0: Input Int (Size = 0; Prec = 0; Scale = 0) [1]
  -- Context: SqlProvider(Sql2008) Model: AttributedMetaModel Build: 3.5.30729.1
  
  INSERT INTO PageItems (Title) VALUES ('this is the title')
  -- Context: SqlProvider(Sql2008) Model: AttributedMetaModel Build: 3.5.30729.1
  
  The thread 0x1190 has exited with code 0 (0x0).
  </code></pre>
  
  <h1>ANSWER</h1>
  
  <p>The solution was three-fold:</p>
  
  <ul>
  <li><p>I was changing a different database than I was looking at in visual studio, solution:</p>
  
  <p>var db = new MainDataContext(@"C:\Users\TestUser\Documents\Visual Studio 2008\Projects\TestPageManager23434\TestPageManager23434\Data\Main.mdf"))</p></li>
  <li><p>that made Update work but not SubmitChanges(), solution was to set the primary key.</p></li>
  <li><p>it still wasn't showing all the chagnes, problem was I had a number of "show data" windows open which weren't being updated</p></li>
  </ul>