msawczyn / EFDesigner2022

Entity Framework visual design surface and code-first code generation for EF6, Core and beyond
MIT License
119 stars 21 forks source link

Entity Framework Designer - VS2022 Edition

Entity Framework visual design surface and code-first code generation for EF6, EFCore and beyond.

For Visual Studio 2022

Model and generate code for both Entity Framework v6.x and Entity Framework Core 2 through 8.

Install with NuGet from the Visual Studio Marketplace

Complete documentation in the project's documentation site

This Visual Studio 2022 extension is the easiest way to add a consistently correct Entity Framework (EF6 or EFCore) model to your project.

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.

Code generation is completely customizable via T4 templates. The tool installs templates that target both EF6 and EFCore, and generate both a code-first DbContext class and POCO entity classes. The DbContext code is written to allow consumption in ASP.Net Core in addition to any other project type, so you'll have flexibility in your development.

Note: This tool does not reverse engineer from the database (i.e., "database-first"). There are other, quite well-maintained open-sourced projects that provide that functionality. Once you've created an assembly from a reverse-engineered database, you can drop it onto an empty design surface and create a model from that, then evolve your code using that model.

You can read more about how to use the designer in the Documentation site.

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

#><#@ assembly name="EnvDTE"

to be

#><#@ assembly name="Microsoft.VisualStudio.Interop"

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?

Shout out and a big thanks

to for providing free development tools to support this project.

We're looking for help!

Let's be honest -- the documentation is woefully out of date. There are a ton of new features in the tool that aren't mentioned in the docs anywhere, and that's just plain not good.

If you're interested in helping out, please drop a note at the GitHub project site. More hands make the work lighter, and I know there are some really bright people amongst the userbase who are much better at writing documentation than I am.

Change Log

4.2.8

4.2.7

4.2.5

4.2.4

4.2.3

4.2.1

4.2.0

4.1.2

4.0.1

4.0.0

Earlier changes at the VS2019 version.