What DbContext project do I get to work with EF?

白昼怎懂夜的黑 提交于 2019-12-21 20:01:37

问题


I'm new to entity framework. I've got EF 4.2, from NuGet. Now I'm hearing it would be good to get DbContext. I've got into the extension manager and tried finding it, but I see about 8 there. Which is the "righ" one? I don't know if this matters but I use both C# and VB.NET. Also, I don't know if this matters or not, but I'm using a data-first model, not a code-first or model-first models, for doing EF development.


回答1:


On your EDMX design surface, right-click and pick Add Code-Generation Item:

Pick the ADO.NET DbContext Generator from the online gallery:

This adds two T4 template files (*.tt) in your solution explorer, and generates the DbContext and the entity classes for you:

And this is the resulting class derived from DbContext for your own project:



来源:https://stackoverflow.com/questions/9040396/what-dbcontext-project-do-i-get-to-work-with-ef

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!