views:

114

answers:

1

I am having trouble with my Linq2Entities model - I might be missing something obvious here.

Here is what I did:

  • Added an EDMX model file
  • Added TableX to the model
  • Went back to SQL Management Studio and updated TableX, changing its primary key
  • Went back to my EDMX file and click "Update Model from Database"
  • TableX updated but incorrectly, not reassigning the new primary key
  • I then deleted TableX from my model
  • Click "Update Model from Database"
  • TableX is now in the "Add" tab, but still in the "Refresh" tab
  • I click on the "Refresh" tab and click "Finish"
  • TableX does not reappear

If I repeat this process in a new project with a different database and (obviously) a different table it still happens.

Why can't I get my table back in the model?!

A: 

This to me is horrible part of LINQ-to-Entities. If I'm smart and remember I usually don't close the edmx files while editing it. I then undo changes until I get back to working version. Otherwise,

  1. Open the edmx file with the XML editor and manually inspect and remove all references to the table that is not "reappearing".
  2. Curse because doing this is a real pain (but works).
  3. Build to make sure you removed all the references correctly.
  4. Update the model from database again.
Michael Gattuso
I sincerely appreciate your answer - and it confirms I am not being mentally removed about this but... surely not?!?! I thought I had "upgraded" from Linq-to-Sql! Someone, please save my opinion of the Linq-to-Entities team and tell me Michael *and* myself have missed something major.
joshcomley
To be precise, the problem isn't LINQ to Entities, the problem is the EF GUI designer. LINQ to Entities is quite solid, but the designer (at least in EF 1.0) is, well, a work in progress.
Craig Stuntz
I should correct my answer, yes, Linq to Entities is surprising solid (I'm using it in production just fine). The designer, though, is horrible as far are fixing mapping strategies gone bad. Thanks Craig.
Michael Gattuso