How can I get my table back after I remove it from my EDMX file in Linq-to-Entities?
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?!
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,
- Open the edmx file with the XML editor and manually inspect and remove all references to the table that is not "reappearing".
- Curse because doing this is a real pain (but works).
- Build to make sure you removed all the references correctly.
- Update the model from database again.
精彩评论