Rod
Rod

Reputation: 4471

What DbContext project do I get to work with EF?

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.

Upvotes: 4

Views: 3208

Answers (1)

marc_s
marc_s

Reputation: 755297

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

enter image description here

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

enter image description here

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

enter image description here

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

enter image description here

Upvotes: 3

Related Questions