For Visual Studio 2022
This Visual Studio 2022 extension is the easiest way to add a consistently correct Entity Framework model to your project with support for EF6 and EFCore2-6.
It's an opinionated code generator, adding a new file type (.efmodel) that allows for fast, easy and, most importantly, visual design of persistent classes. Inheritance, unidirectional and bidirectional associations are all supported. Enumerations are also included in the visual model, as is the ability to add text blocks to explain potentially arcane parts of your design.
While giving you complete control over how the code is generated you'll be able to create, out of the box, sophisticated, consistent and correct Entity Framework code that can be regenerated when your model changes. And, since the code is written using partial classes, any additions you make to your generated code are retained across subsequent generations. The designer doesn't need to be present to use the code that's generated - it generates standard C#, using the code-first, fluent API - so the tool doesn't become a dependency to your project.
If you are used to the EF visual modeling that comes with Visual Studio, you'll be pretty much at home. The goal was to duplicate at least those features and, in addition, add all the little things that should have been there. Things like:
and many other nice-to-have bits.
Note: This tool does not reverse engineer from the database (i.e., "database-first"). Microsoft has provided tools for that, and there are other, well-maintained opensourced projects that provide that functionality as well.
For comprehensive documentation, please visit the project's documentation site.
For the VS2019 version, click over to Entity Framework Visual Editor
Migrating from VS2019 You'll have to change a line in your model's .tt file to accommodate how Visual Studio 2022 handles library imports in text templates.
Change line 5, which reads
That's it. Of course, if you customized any of the standard templates, you'll have to go through the customizations the same way you've always done and bump your changes up against the new templates. Not much has changed that didn't absolutely need to be changed due to the VS2022 differences, but there may be a bugfix or two your customized templates don't have. But, hey ... if you've been customizing the templates, you know the drill, right?
Earlier changes at the VS2019 version.