title: The Ghost of a Renamed Table
body: <p>I have renamed a table in a SQL Server 2008 database, from eL_CourseStepUserNotes to StepUserNotes.  I renamed the table using the SSMA.</p>
  
  <p>The table is used in a ASP.NET 4.0 app.  I use LINQ to SQL for all CRUD.  The problem is that the following code:</p>
  
  <pre><code>    dbDataContext db = new dbDataContext();
      var k = (from c in db.StepUserNotes
               where ((c.CourseStepFK == q.CourseStepFK) &amp;&amp; (c.UserFK == q.UserFK))
               select c).FirstOrDefault();
      try
      {
          db.StepUserNotes.InsertOnSubmit(q);
          db.SubmitChanges();
      }
      catch
      {
  
      }
  </code></pre>
  
  <p>Fails on the db.SubmitChanges line, saying:</p>
  
  <pre><code>SqlException was caught. Invalid object name 'eL_CourseStepUserNotes'.
  </code></pre>
  
  <p>Ie, the old name for the table has come back to haunt me.</p>
  
  <p>I have deleted the old LINQ to SQL dbml file and created a new one.  I have searched through all the source code for strings that contain the old table name.  Nothing.  The code compiles...</p>
  
  <p>Where else can I look?</p>
  
  <p>The error is coming back from SQL Server, and using the utility for listing all foreign keys in a sql server database shown in SO question:
  <a href="https://stackoverflow.com/questions/1957306/sqlneed-to-change-constraint-on-rename-table">sql:need to change constraint on rename table?</a></p>
  
  <p>reveals no sign of the old table name in FKs either.</p>
  
  <p>I am at a complete loss as to where to look or what to try next.  Any suggestions?</p>