开发者

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,

  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.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜