What DbContext project can I work with with EF?

I am new to entity structure. I have EF 4.2, from NuGet. Now I hear that it would be nice to get a DbContext. I got into the extension manager and tried to find it, but I can see about 8. What is β€œtall”? 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 use the first data model, not the first code or model model for developing EF.

+4
source share
1 answer

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

enter image description here

Select 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 DbContext and 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

+3
source

Source: https://habr.com/ru/post/1393442/


All Articles