S07E04 - Powering Up with Erik Jensen: An Introduction to EF Core Power Tools
Sponsors
Support for this episode of The Modern .NET Show comes from the following sponsors. Please take a moment to learn more about their products and services:
- Metalama, reduce your boilerplate code by up to 15% with Metalama’s C#-to-C# template engine and reduce your code complexity today!
Please also see the full sponsor message(s) in the episode transcription for more details of their products and services, and offers exclusive to listeners of The Modern .NET Show.
Thank you to the sponsors for supporting the show.
Embedded Player

The Modern .NET Show
S07E04 - Powering Up with Erik Jensen: An Introduction to EF Core Power Tools
Supporting The Show
If this episode was interesting or useful to you, please consider supporting the show with one of the above options.
Episode Summary
In this episode Erik Jensen, a software developer and Microsoft MVP from Denmark, who has extensive experience in building tools for .NET developers, discusses Entity Framework Core (EF Core) Power Tools. The conversation begins with Erik and Jamie reminiscing about their first encounter at the MVP Summit 2024 and expressing appreciation for the positive impact his tools have had on developers. Erik has been an MVP for 15 years and has worked to maintain tools that assist developers in accessing and utilizing SQL Server and Azure SQL Database.
Erik shares an overview of EF Core Power Tools, which originated to fill a gap when EF Core was introduced. Initially, the lack of graphical user interfaces due to the cross-platform nature of EF Core limited developers to command-line tools. As a response, Erik designed the EF Core Power Tools to provide a user-friendly graphical interface that allows developers to reverse engineer existing databases into EF Core models easily. This process can save developers significant time and effort by generating code that represents their database schema and relationships, easing the transition to working with EF Core.
The discussion delves into the various features of EF Core Power Tools, emphasizing the ease it brings to the reverse engineering process. Erik explains that users can select specific tables and customize the code generation process through various options in the tool’s interface. This flexibility allows developers to fit the generated code to their preferences and structure while maintaining an efficient workflow. Erik also touches on the tool’s command-line version, which allows users on macOS and Linux to access similar functionalities.
A notable part of the conversation covers the tool’s recent addition of static code analysis for SQL databases. As Erik explains, static analysis serves as a helpful mechanism for developers to follow best practices and avoid common pitfalls, mirroring the guidance that a DBA (Database Administrator) might offer. This analysis operates independently of the compilation process, providing developers with insights and warnings that can help them optimize their database structures and queries.
The conversation highlights Erik’s commitment to making EF Core Power Tools accessible and easy to use. He provides straightforward guidance for developers who want to get started with the tools, including directions for installation through Visual Studio and documentation on using the tool effectively.
Episode Transcription
Hi everyone,
Just a quick thing before we start: this episode was recorded in the middle of summer, which meant that Erik needed to have his office window open. It’s possible to hear the outside traffic throughout, but rest assured that our editing team have done what they can to reduce it’s presence.
It’s not that noticable and shouldn’t affect your enjoyment of the show, but I wanted to give you a heads-up. Also, do remember that there’s a full transcription available at the show’s website; so check that out, too.
Anyway, let’s get to it.
So, I think my mantra for creating things like these tools is, “should be easy to get started and there should be a like an easy happy path but then if you want to deep dive and do a lot of options or even a t4 templates you can also do that,” but there should be a simple happy path with good error reporting if something fails
Welcome friends to The Modern .NET Show; the premier .NET podcast, focusing entirely on the knowledge, tools, and frameworks that all .NET developers should have in their toolbox. We are the go-to podcast for .NET developers worldwide, and I am your host: Jamie “GaProgMan” Taylor.
In this episode, Erik Jensen joined us to talk about EF Core Power Tools, and how you can use his project to increase your productivity with EF Core-based databases, regardless of the database technology used; if it’s supported by EF Core, then the Power Tools extension supports it to.
The one that’s definitely used the most is what in a tool is referred to as reverse engineering. Where you point to an existing database, which can be some of the database types I mentioned previously. Like SQL Server, as a SQL database, Postgres, Oracle, MySQL, and Firebird. And then the tool asks you for a number of options, like you can specify what namespaces you’re using, and where the files are laid in your project, and many, many other options. And then when you press OK at that point, as you said, Jamie, the tool generates a DB context and some classes that represent your tables with navigations between the tables based on discovery of foreign key relationships
We also briefly touched on the MSBuild.Sdk.SqlProj project and its goal of giving cross-platform .NET developers a way to both describe and build their ideal database schema in code. We also covered Erik’s personal process for dealing with feature requests, and how developers can ensure that that are providing valueable feedback to open-source projects; a subject that will come up again soon with future guest Scott Harden.
Anyway, without further ado, let’s sit back, open up a terminal, type in dotnet new podcast
and we’ll dive into the core of Modern .NET.
Jamie : [1:21] Wow, 15 years. That’s amazing.
Jamie : [1:26] So I wonder then, just for folks who are listening in and going, “wait a minute, what are they talking about? Who is this guy?” Would you mind giving the folks a bit of an elevator pitch sort of introduction, like a little bio or something?
Erik : [1:38] Absolutely. Yes, my name is Erik, and I’m from Denmark, in Europe. I am a software developer and architect and, In my day job, I work for a consulting company, helping people deploy and also do custom, deploy applications to the cloud in order to do custom development for them.
Erik : [2:09] Apart from that, I’m a Microsoft MVP, and so in my spare time, I do some MVP work, that involves, for me, for my part, maintaining a number of tools and libraries to help developers work with .NET and data access. So that can be like raw database access with the SQL client or some more sugar-coating on top like Entity Framework, for example. Entity Framework Core these days, but used to be Entity Framework. So I have a a lot of tools that are published on Visual Studio Marketplace and some libraries are published on NuGet. And I also contribute to some of the Microsoft repositories like EF Core and SQL Client. So my passion is helping developers make the most of basically SQL Server and Azure SQL Database, I suppose it boils down to. But trying to do that without upsetting your DBA.
Erik : [3:21] Yeah. So I used to be, I’m now a developer technologies MVP. So MVPs are kind of put in buckets according to what product group they are attached to, so to speak. But I actually used to be a data platform MVP and that was, like data platform back in the day basically meant SQL Server and some kind of other SQL Server services that was in the box product. I wasn’t an angry old DBA by that time because that’s many years ago.
Erik : [4:01] Yeah and that’s that’s, I think that’s the elevator pitch.
Jamie : [4:07] Amazing. So yeah uh one of the things that we’re um definitely going to be talking about today is like entity framework and things like that. Just because, you know, it’s something that i’m super interested in. But I think um whati’m really interested to talk to you about is the EF Core Power Tools. So I know just because i’ve used it a whole bunch, but I wonder for folks who are listening in if they haven’t tried out the EF Core Power Tools, or indeed the EF Power Tools, could you talk through what that is and how that came to be?
Erik : [4:44] Yes, so EF Core Power Tools, came to be because when EF Core was introduced, it was made for .NET or what used to be called .NET Core. And there was no purpose of doing GUI heavily tools because everything had to be cross-platform. And there was also a limited amount of resources. So the tooling was command line based. And the team provided also some tooling for doing what I call database-first modeling.
Erik : [5:25] The tool is referred to as scaffolding, which is kind of a little bit different, but it’s also referred to as reverse engineering. So the idea is basically that you have an existing database, maybe one you make because you need to do something new, or maybe one that’s there already. And that is the database that your application is going to talk to. So the workflow, the ideal workflow when working with EF Core, in my opinion, is that you actually design your database, or maybe you just have to go, “we’re compromising with whatever somebody else designed at some point in time many years ago,” and you’re unable to change it, so you just have to live with it. It can be both scenarios. And then you have some tooling that can generate the code necessary to speak with that database and deserialize any records and that rows in that database into instances of C# classes; usually called an EF Core model in EF Core speak.
Erik : [6:39] So I felt there was a need for graphical tooling because the predecessor of Entity Framework Core, which was called Entity Framework, just Entity Framework, it actually used to have some visual tooling. And it was basically heavily based on the fact that you could do stuff with it in Visual Studio and it was .NET Framework tied to .NET Framework and Windows and very much tied to on-premises SQL Server installations.
Erik : [7:13] Whereas the design goal for EF Core was really that to be cross-platform and be much less hard-coded against a particular database system. So that supports PostgreSQL, Oracle, MySQL, Firebird, SQLite. And that’s maintained up-to-date providers for all those database systems with EF Core. So I wanted to create a tool where you could point to one of those database types and get code generated, but without having to know some arcane command line syntax and also make it easier for not developers that are used to working in Windows and Visual Studio, but maybe don’t know a lot about cross-platform work and command line tools, to get them up to speed quickly to start working with a database in C#. So with the blessing of the EF Core team—which is the team of Microsoft that maintains the Entity Framework Core libraries, and publish them on NuGet, and also do a lot of evangelism and documentation around those packages—I was allowed to create EF Core Power Tools.
Erik : [8:35] The team used to publish something called EF Power Tools, which was for the old Entity Framework, and I’m actually now kind of maintainer of that. I’m trying to not maintain it, but so I thought it was prudent of me to ask them if it was okay, but they obviously had no plans to do something similar themselves, so they let me run with it.
Jamie : [9:05] Right, yeah.
Erik : [9:07] Power Tools was launched in 2017. It was probably a couple of years after, I think it was like around EF Core 2 or something, so like a couple of years after .NET Core was initially launched and now it has over 400,000 Visual Studio users; its Visual Studio marketplace counts in installs. So that means that it’s actually, that extension is actually installed in 400,000 Visual Studio instances. So that’s quite frightening.
Jamie : [9:48] Yeah.
Erik : [9:51] In that, whenever I do something that can potentially be breaking, I will definitely hear from someone about it.
Jamie : [10:06] So because that was going to be one of my questions about like, because I know that EF Power Tools existed and i’ve used EF Core Power Tools, and I was wondering if they were related. And obviously you’ve answered that right? In that EF Power Tools was a a thing that was created um by the ef team back in the day.
Jamie : [10:28] Yeah and that they’ve sort of given you, I guess, permission. I’m not sure if that’s the correct word, but you approached them and said, “hey, I’m thinking of doing something similar.”
Erik : [10:38] I approached them and asked them if it was okay that I went with this, and they didn’t say no, so I went ahead and did it.
Jamie : [10:50] Okay. So I guess the immediate question is, you know, you kind of touched upon what EF Core Power Tools allows you to do. Now, like I said, I’ve used it on a project for a client very recently, so I know some of what it can do. So to give you some kind of background information and to give the listeners background information, I was building some code which would communicate with a preexisting database. And so EF Core Power Tools allowed me to, in effect, in fact, reverse engineer that database into a DB context and a whole bunch of C# objects, which represented all of the tables with all of the properties and all of the, excuse me, all of the navigation properties and things like that. So I know that it can do that. But I was wondering, can you talk to like a little bit more of what EF Core Power Tools allows you to do?
Erik : [11:47] Yeah, it has a few features.
Erik : [11:50] Like the one that’s definitely used the most is what in a tool is referred to as reverse engineering. Where you point to an existing database, which can be some of the database types I mentioned previously. Like SQL Server, as a SQL database, Postgres, Oracle, MySQL, and Firebird. And then you can pick which tables that you want to include in your code base. So maybe it’s a huge database and you don’t want to include all of them. So there’s a nice interface where we can set up checkbox and do some filtering and stuff. And then the tool asks you for a number of options, like you can specify what namespaces you’re using, and where the files are laid in your project, and many, many other options. I have quite a long wiki page about how you can configure the tool, and what each of the options mean, and the various effects that you get out of turning them on and off, and so on. And then when you press OK at that point, as you said, Jamie, the tool generates a DB context and some classes that represent your tables with navigations between the tables based on discovery of foreign key relationships.
Erik : [13:22] And from there on, you can basically start working with it and run queries and do updates and deletes and so on on your, and inserts on your database that this code generated thing represents. I’ve also expanded it now because now I have tooling that can kind of look at the schema and do something with it. So I’ve also expanded it to related things like generating an entity relationship diagram from your existing database. And the most recent thing I’ve added is a static code analysis of your SQL database, Microsoft SQL database, based on the fact that the tool knows about the tables and relationships and columns in your database.
Erik : [14:20] I used to have a migrations tool as well, which kind of was a small UI on top of the migrations tooling from Microsoft, but I’ve actually abandoned that because there is now some tooling in Visual Studio well hidden, that allows you to…
Jamie : [14:43] Right, okay. I do have a question about the static analysis stuff in a bit, . But I was wondering, so like I said, I’ve used EF Core Power Tools and I genuinely think it’s really good. I’m not just saying that because you’re a guest on the show.
Jamie : [15:01] And you talked about how we kind of got to where we are in that EF Entity Framework had a thing called Entity Framework Power Tools. But I’m wondering, before we talk about the static code analysis, if that’s something you’re able to talk about, I’m just wondering, so you’ve talked about how this is, and I know the answer to this, but you’ve talked about this, about how it works with Visual Studio and how you’ve walked away from one or two features because those are now provided within Visual Studio.
Jamie : [15:36] And I’m skipping over—for the folks who listen in a lot, they know that I plan out questions and share them ahead of time. Skipping over a bunch of questions just to get to one that I think that listeners will maybe want to know about. You mentioned Visual Studio a lot. This is a Visual Studio extension. But, are there plans to support maybe devs who aren’t using Visual Studio? Like if I’m using VS Code or Rider, I realise that you are a solo developer working on this and it is open source, but is there at least an idea for the future for those? Totally okay if there isn’t, by the way.
Erik : [16:19] No, no, but I think that’s definitely a very relevant question. And it turned out like I had like 10, 12 issues, maybe more, in my GitHub repositories. Like when people come up with ideas, I welcome them to go to my GitHub open source repository from where I maintain the tool, the source code resides, the documentation resides, and people come with the bugs reports, of course, if some things aren’t working as they expect. Sometimes things don’t work like that because I haven’t documented it well enough or have not been able to point them well enough to documentation about how they can change that behaviour.
Erik : [17:03] But a lot of people ask for like, “I’m using Rider and I’m on a Mac, " “I’m using VS Code.” Not a lot of people actually wrote, “I’m doing everything from the CLI, can you help me?” But essentially they were using some other more high-level tool than just the command line to do .NET development. A lot of people using Rider, obviously, on both Windows and other OS platforms. So actually recently, I think it was like maybe a year ago, I actually decided to bite the bullet and created the EF Core Power Tools CLI. So the tool is actually also available as a command line tool, which means that you can run it from the terminal in Rider. If there is such a thing, I assume there is. You can definitely run it from the terminal in VS Code.
Erik
:
[18:07] And yeah, if you have some other tool, if you can run .NET command line tooling, you can run it. So it’s a .NET global tool, which means first you must have .NET installed in order to use it. And then you can basically just install it by typing dotnet tool install
and then the code name of it, which is your <codeErikEJ.EFCorePowerTools.Cli or something like that. So then the tool will be downloaded from Nuget and will become available as a command line tool on your machine. It’s only the reverse engineering part that’s currently available, but it’s a good start. And I think it has about 100,000 downloads, so some people must be using it. Yeah, and it’s like, I assume those 100,000 downloads are explicit because you actually have to invoke a command in order to install it, so…
Jamie : [19:14] Yeah, that’s genuinely amazing. I wasn’t sure what to expect by asking that question about, “is it available outside of Visual Studio?” Just because I realise you’re a solo developer and there’s a lot of work that goes into building something for any kind of modern programming platform, any kind of tool for that. So that’s wonderful.
Erik : [19:40] I have this really nice UI for picking the tables in Visual Studio extension. And that was actually contributed by somebody from the community. I think it was an Italian MVP. It’s not really important who it was, but somebody actually stepped up and said, “I think it’s a little bit crude what you have now, Erik, " because I’m not a WPF developer. So actually he stepped up and made this really nice kind of tree-like user interface for picking objects in a database. And likewise for the CLI, some guy, I did some kind of rough thing and some person from the open source community stepped up and kind of streamlined it a bit and made it more testable and so on. So yes, I am the sole maintainer of this project and it’s all in my name. I don’t have a big org or anything supporting me. But yeah, sometimes I get a little pat on the shoulder and that’s that’s really nice.
Jamie : [21:01] Yeah, so so we’ve talked about how um it’s available outside of Visual Studio, we’ve talked a little bit about how there’s other contributors and stuff; and I think that’s really important uh to point out that, you know, I said earlier when you’re a solo developer And yes, it is in your GitHub repo, I guess. But the other people are involved, right? A lot of people tend to kind of forget that these open source tools that are around, they kind of forget that there is a person on the other end working on it, right? There’s that wonderful XKCD image of loads of different blocks all piled up on top of each other, making a vague tower and how it’s all supported by one block of, you know, some developer in Nebraska working out of his basement or whatever. So I think that’s, it’s very important for folks to remember.
Jamie : [21:51] And, you know, what I will do for the show notes is I’ll go through the commit history and try to pull out the, the usernames for the folks who have contributed those, those parts that you were talking about there. Cause I think it’s important to sort of shout them out, you know, to say, “Hey, this, this amazing person has come along and helped with building this,” or whatever. So yeah, definitely.
Jamie : [22:10] So I wonder before we go on to anything else, then you did say about the static code analysis. So let’s talk about that really quickly, because that sounds like it’s a really, that to me sounds like it’s a huge chunk of work. So before we go into what it is, let’s have a really short discussion about what static analysis is, right? Because I think that’s kind of important in case folks don’t know what that is, right?
Erik : [22:36] Yeah, yeah. Yeah, so people that use .NET are probably already taking advantage of it. Basically without knowing, because the newer .NET SDKs actually comes with a number of what is called .NET analysers, and I think some of them are enabled by default. You could tweak how many of them are enabled and what should happen if the rules are broken. Like now they’re just configured to produce some build warnings.
Erik : [23:13] So the analysers are kind of… let me put it another way: It’s nothing to do with compilation of your code. Your code compiles, it builds, it can run anywhere, but it doesn’t really just… Maybe there are some things that you could do better. The language allows what you have done, but maybe there are some practices that used to be okay, but now have been improved because something was added to the language or through the framework. And those analysers are helpful in pointing you in the right direction. So they’re kind of opinionated about things you should or could do with your code base, but it’s not like syntax errors that prevent your code from building. Did that make sense, Jamie?
Jamie : [24:04] Yeah, yeah. So it’s more looking for potential issues with the code rather than actual errors with, like you say, the syntax, right? So it’s more like for folks who have ever turned on a warning, I know that this isn’t static code analysis, but when you turn on warnings as errors, it stops your build from completing just because the compiler warnings are now in your face, right? It’s kind of like that, except that it’s kind of suggesting maybe “better” in bunny quotes, ways to do things or a slightly different way of doing things like you said things have changed in the 20 what four years that C# has been a thing .
Sponsor Message
The following is a paid advertisement.
Did you know it’s common for a business application to contain 15% repetitive code—just because of meta-programming limitations in the C# language? Why write boilerplate manually when a machine could generate it on-the-fly when you compile? Enter Metalama, the new meta-programming framework for .NET.
Their C#-to-C# template language is simply amazing! Logging, caching, memento, observability… If it’s repetitive, Metalama can automate it.
Visit metalama.net today and learn to automate your code patterns with their free edition. Remember, it’s metalama.net with one L.
That’s m-e-t-a-l-a-m-a-.net
Jamie : [24:47] So then how does that fit with a database then because you know when you said when you said um and I may have noted this down um slightly wrong but you said, “static code analysis for SQL databases.” i’m like, “wait hang on, what?” So is it just essentially doing the same kind of idea but with maybe the way the tables are created, and the the joins, and the foreign keys, and like the maybe you’ve got tables as functions, and things like that is that what it’s doing?
Erik : [25:20] That’s basically what it’s doing. So if we look a little at the history some tooling was in a special edition of Visual Studio was introduced in 2010, Visual Studio Database Edition or something like that, the, nickname was “Data Dude”, and that introduced some really powerful technology and an underlying framework that’s available now, there’s a NuGet packet called DacFx. And that framework contains various bits and parts, in particular to support database projects, which is your database schema under source control, and then the ability to check that source controlled database schema and apply it to a running database, to your production database. So, it’s that database schema under source control is basically describing… So at one point you have something that one-to-one matches your production database, but then you’re making some new column or adding a table or an index. And then that is the state that you desire for your database in order to support a new feature, for example. And then when you deploy that desired state, the tooling will bring the production database in that desired state without any data loss.
Erik : [27:01] But this DacFx framework also contains some tooling to do static cone analysis. And built into Visual Studio there’s actually like things like 10 maybe Microsoft produced rules that you can turn on. You simply just go to project properties and go to the code analysis tab and turn them on. Andthen you may get some build warnings about some best practices that you’re not adhering to. And I have also published some other cross-platform way of building database projects that includes even more rules. I have done some archaeological digging in GitHub and found that other people, back in the day, had made rules that were kind of left in the dust so I have brought them up to date and made them work with the latest versions of SQL Server.
Erik : [28:06] So and those rules were also made by some people working closely with Microsoft but not Microsoft themselves But with that I think it’s like the whole sum of rules now are over 50o with that rule set you get, basically you get like it’s I think i’m thinking a little bit of it as a DBA looking over your shoulder and said, “Eric, I know you’re just a C# developer. But here’s my take on what you can do better. " And the nice thing is that you can do that in advance.
Jamie : [28:48] Okay, so because one of the things that I’ve always known about Entity Framework is, this was back in the Entity Framework days, is that a lot of the big public voices were always saying, “hey, Entity Framework is,” even the folks who are pretty close to the team were saying, “Entity Framework is great, but also make sure you have a DBA take a look at what you’re doing and what Entity Framework is able to create for that.” So I liked the idea of being able to do some kind of rules-based static analysis on my schema without having to bring, not as a replacement for bringing a DBA into the fold, but like to cover those first things that a DBA is going to ask right ? Because they’re going to walk in with you know I have maybe these exact same 50 rules that um that I would expect a database to have um to to adhere to and i’m gonna i’m gonna do that and then um maybe once i’ve checked those I don’t have any time and so maybe I don’t have the time to actually go back and do the the slightly more shall we say advanced set of rules so being able to add I guess add a click turn on this analysis and actually do that to save a little time so then when I bring the DBA in they can focus on on something, right?
Erik : [30:10] Yeah, and it’s simply just a flip, a switch you flip. And of course, if you and the team you’re working with find out that some of the rules don’t really apply to you, you can easily disable them. I have already deployed these. As I said, I’m working for a consultant company, so we’re doing various projects for our customers. And I’ve already flipped the switch on multiple projects and improved the database schema in those projects by doing so. So, yeah. Standing on the shoulders of giants.
Jamie : [30:47] 100%.
Erik : [30:48] Yeah. So Power Tools actually also has, now we’re talking about this database project thingy, it also has the ability to generate code from a database project. So if you’re doing greenfield development, you can basically start out by creating your create table, create index, create foreign key constraints, et cetera, create check constraints, and so on in your database. And then you can point Power Tools into that database project, and it will generate the DB context and classes based on that, rather than a running database, a live database.
Jamie : [31:33] I really like that idea of being able to switch it on, see what it is, switch it off. But then I guess my question there, and this probably goes back to what we talked about earlier, about since EF Core Power Tools is a Visual Studio thing, can you use it outside of it? Can I also use this static analysis stuff outside of Visual Studio? My only thinking is, what if somebody, you might want a regression test, I guess, is probably not the right word, in your CI/CD pipeline, “did someone make a change to their schema and has it broken any of these static analysis rules?” Do I need Visual Studio in my CI/CD pipeline to be able to do that? That’s my question.
Erik : [32:18] Yeah, if you’re using the standard database project that is currently available in Visual Studio, you need a Visual Studio build on a Windows machine in order to do it. So if you’re doing cross-platform development, or if you’re using agents that run on Mac or Linux, you’re at a dead end. But I’m actually the contributor to a project that fixes exactly that issue and lots of other things. And that project also includes the static code analysis feature. Again, just switch it on in that project type, and and it will run both on your local machine and in any type of, pipeline that on any machine where you can run .NET basically.
Erik : [33:12] It’s called the project, it has a very strange name, it’s msbuild.sdk.SQLproj, s-q-l-p-r-o-j. But it’s basically I think it was, I’m a contributor to the project but I didn’t actually launch it. But I think the idea is that there was this place where they’re using a lot of Mac machines and they couldn’t build database projects, but they really liked the idea behind them. So some guy who was very knowledgeable about MSBuild and build targets and whatnot took advantage of the fact that you can actually define your own .NET SDK and publish that as a special type of Nuget package. And so he enabled building dacpacs in this alternative project type on any platform, including his Mac machine.
Jamie : [34:16] Right. Nice.
Erik : [34:19] Microsoft is working on it, but they’re not quite there yet. So we’re helping. In the meantime, this project is helping Microsoft.
Jamie : [34:29] Right, yeah, because I guess, you know, with .NET and all of the .NET tools being open source, I guess that’s kind of the… I guess the argument, right, in that .NET itself will be owned by the .NET Foundation, which isn’t Microsoft, but Microsoft sort of gifts time over to, whereas the tools surrounding it, I suppose, are meant to be community-based, right?
Erik : [34:57] Yeah. Or provided by Microsoft, but yes. So, yeah.
Jamie : [35:03] Right.
Jamie : [35:04] Cool. Okay. So, okay, so there’s that. That so I will i’ll get some links to that and put that in the in the show notes for people to check out.
Erik : [35:12] Yes.
Jamie : [35:12] I think that’s a really cool idea.
Jamie : [35:14] So what about , let’s talk about the potential unique challenges that you’ve had to overcome when you’ve been working on EF Core Power Tools, right. Because I can imagine it’s a, because it’s an extension which you said earlier it has like a WPF front end to it, you can pretty much guarantee, at least for the front end part, it’s going to be Windows, it’s going to be inside of Visual Studio. So you can bring a bunch of assumptions to it. But like, I get the feeling that you can’t really assume that everyone will use Entity Framework Core in the same way, right? Or are you doing that? Are you saying, “hey, you know, the documentation says you have to do it in this way. I will just assume everyone’s following the documentation and doing it the standard way,” not that there isn’t a non-standard way, but you know what I mean. And what challenges come from creating something that is for a cross-platform technology, but is primarily used within Visual Studio rather than cross-platform itself? I know that we’ve got the CLI, we’ll talk about that later.
Erik : [36:25] Yeah, yeah. So, yeah, like one of the challenges is, if we just step back, like Microsoft actually does provide competing tooling. It doesn’t have, and that provides kind of a layout for how things are, like a baseline for how code is generated and how it’s laid out on disk and so on. And I’ve taken that as the assumption that that is what most people would go for. But then I provided a number of options that they can turn on during code generation, simply from the UI, trying to think of a good example. “I want pluralization on or off, " for example, so like my tables are all singular, but I want my entity names to be plural or vice versa.
Erik : [37:34] Maybe doing something with the names of objects, like if it’s an old database, all the tables could be prefixed with TBL, and I don’t want that. Can you provide an easy way of getting rid of that? Many other tweaks and knobs you can turn to get the code generated in a kind of way that appeals to a number of people. Of course, often there’s people that have very specific requests regarding something they personally think is a good idea, but maybe they’re the only person in the world asking for it. Luckily, the tools actually also provide some ways of doing that, because today the code is actually generated based on some T4 templates, which is a .NET-based templating system. That is used for code generation. So it’s a little bit like, I haven’t really done a lot of work with them, but maybe Razor webpages where you can mix backend code and frontend code, or maybe even like classic ASP where you could mix frontend markup and then some backend code.
Erik : [38:57] So it’s a templating language. The tooling is not super great, but there is some. And with those templates in your project, you can actually tweak the generated output to look more or less any way you want it, as long as it’s compilable to C#. So I try to provide something where you’re basically just clicking next, next, next, and then all is good, and you are done. Lot of developers I think they just take that and then get on with it and more people some people are inspecting or introspecting the generated code and over, in my opinion maybe, overthinking it, um and want to tweak it in various ways so there’s knobs that they can do that.
Jamie : [39:54] Okay. So how does that, I guess, i’m always interested to find out how a open source maintainers manage I guess, the expectations of the users. We’ll talk about how EF Core Power Tools works in a moment, but like if someone you know I can imagine because ef got power tools has as a very large user base, right? You said earlier that, you know, there’s a lot of installations of it, and mostly those are installations [are] within Visual Studio, unless it’s a CLI, because either you have to install inside a Visual Studio, or you have to actually physically run a command to install it for the CLI. So we can assume that those installations are engineers, are real people’s machines, rather than it being, you know, like a CI/CD pipeline, for instance.
Erik : [40:50] Yeah, I mean, it’s a little more doubtful with the command line tool because you can actually install that. You could potentially just install that on a build server if you wanted to and run it there. I don’t know why you would want to do that, but it’s possible. But yes, definitely, the people that have installed my extension, they have deliberately decided to do so. So they have certain expectations about what they’re getting.
Jamie : [41:21] So then how do you, I guess, how do you manage those expectations, right? Somebody comes to you and says, “hey, you know, I’ve got this idea for a thing, and I, in quotes, want you to build this for me.” Or perhaps, you know, somebody says, “hey, I want this thing to exist.” How do you go about managing that from a, I am a single person doing this thing, right? How do you do that?
Erik : [41:56] I mean, of course, I’m expecting a polite and sober tone in our conversation. And if that’s not the case, then I can probably get dismissive and, I mean, at least urge them to keep a good tone of voice. But if they’re past that, and if it’s a genuine request, then I usually try to take it seriously, and if there’s some unclearness about it, I try to make them elaborate and maybe provide some examples of what they’re wanting to achieve. If they start talking about things like, “when can you have this available” and so on then I have to remind them that this is a free tool and I usually ask them are you going to sponsor me? Now we have agreed on this could be a sensible thing, to add and we have a design proposal and then I usually ask them, “are you interested in doing a pull request and I will review it?”
Erik : [43:10] If people are reporting issues more than just feature proposals then I have recently become very quickly at dismissing them if they it’s like when they do that I ask I have a form they have to fill in with some information I request from them, like if they encounter an issue they have to tell me the steps to get to that issue and it’s usually, in this context, it’s actually usually quite easy because it’s just a question about supplying me with some create table statements that breaks the tools somehow and then saying, yeah, well, I point to a database with these tables and then this happens and I expected that to happen. But if they don’t make the extra effort to just sit down for five or 10 minutes and supply me with that information, I’m usually relatively quick as actually closing the issue and say, “sorry, I can’t help you. You did not provide any actionable information here. You’re just saying it doesn’t work.”
A Request To You All
If you're enjoying this show, would you mind sharing it with a colleague? Check your podcatcher for a link to show notes, which has an embedded player within it and a transcription and all that stuff, and share that link with them. I'd really appreciate it if you could indeed share the show.
But if you'd like other ways to support it, you could:
- Leave a rating or review on your podcatcher of choice
- Head over to dotnetcore.show/review for ways to do that
- Consider buying the show a coffee
- The BuyMeACoffee link is available on each episode's show notes page
- This is a one-off financial support option
-
Become a patron
- This is a monthly subscription-based financial support option
- And a link to that is included on each episode's show notes page as well
I would love it if you would share the show with a friend or colleague or leave a rating or review. The other options are completely up to you, and are not required at all to continue enjoying the show.
Anyway, let's get back to it.
Jamie : [44:15] Sure, sure. And I think it’s important for folks who are listening to podcasts, approaching people who are in that open source area to actually know that these folks are perhaps individual people like yourself, or part of a very small team of people who are creating something in their own time as like a hobby project, a passion project, a labor of love, as it were, so that then they can provide something to the community. And so I’m always interested to know how people sort of approach that when they are the main contributor to an open source project. So, yeah, thank you for that.
Erik : [45:06] It’s a delicate subject, but it’s like maybe I got more. It’s also, for me, a maturity thing. I’ve been working with open source projects for approximately 15 years now, including another extension that has over a million installs. So I wouldn’t say my skin is getting tougher, but it’s more like, yeah, I don’t get, i’m probably better at getting less emotionally involved than I was back in the day maybe i’m just getting older.
Jamie : [45:42] No I get that I get that. Yeah , no I fully understand But yeah i’m always interested to know.
Jamie : [45:53] So let’s talk really briefly about out how it all works right. Let’s say just as a quick run through of one of the features of entity framework or power tools right. I have a database project do a right click and reverse engineer, I provide a connection string, it hen select parts of the schema—maybe I want the whole schema, maybe I just want parts of the schema—to reverse engineer, and then I push a button, some magic happens and out pops a C# project with DB context and a whole bunch of C# objects, which represent my tables, my views, you know, all that kind of stuff. So what’s that bit? That’s the magic, right?
Erik : [46:37] If it’s SQL server. Yeah. Yeah. So, so what, what is, what is the magic do? So, so of course, um, Visual Studio is a .NET Framework thing, which runs on Windows so it doesn’t, Visual Studio doesn’t really know about .NET Core only indirectly and if you think it does it’s because the Visual Studio tools guys are really good at doing some magic.
Erik : [47:09] What happens behind the scenes is, I actually deploy a command line tool, I unpack a command line tool. When you invoke the reverse engineering process, I check if it has been unpacked once already to avoid unpacking it every time. And then I look at the project, so I provide parameters that relate to the project, like what is the root folder of the project that you are generating code in, and what is the namespace, and useful pieces of information that can go into the code generation decisions about where should the files be placed, and what should the namespaces be, and so on. And together with all the selection of tables and other database objects you have selected, and all the values for the various options you have selected, I pass that on to my internal command line tool and let that run. And then I try to report back some status about how it went to Visual Studio via some JSON communication. And hopefully I’m able to show that to the user if it went well or didn’t go so well.
Erik : [48:26] And the result should be that they will get some kind of status message saying, “well these errors were encountered during the code generation,” or, “these warnings occurred during code generation,” and the files, the generated files should be placed on the disk and put into the project. So having this external command line tool also was the basis for the CLI. So it turned out it wasn’t as incredibly hard as I maybe had feared it would be to do a CLI tool. The main effort there was actually to create a configuration file that didn’t look like the internal configuration file that the tool uses today. So kind of a more human, readable, with some nested options and a good editing experience in other editors, like, for example, Visual Studio Code, where you can get the code completion and suggestions and so on for JSON files with some JSON schema magic.
Jamie : [49:37] Right. So, yeah, it kind of blows my mind just how much there is going on in the background, especially because I didn’t know. No, you said that Visual Studio isn’t really aware of .NET Core, or rather, modern .NET, and that the Visual Studio team do some magic to hide that from you. I didn’t realize that.
Erik : [50:04] But Visual Studio is a .NET framework. So at the end of the day, it doesn’t know anything about .NET. It’s just a command line tool on your machine, like all other command line tools, apart or far from that. And I was lucky enough actually to at an MVP summit to kind of, sit down with one of the developers from the EF Core team and discuss how this could be done and how it would be possible to support multiple versions of EF Core. So I have code generation both for EF Core 6 and 7 and 8, and I guess soon I will have it for 9. So that means I have to like pack and build X number of zip files for each version of EF Core. And that zip file, it contains my command line tool, and then that depends on the design time, services, and the providers that the tool supports. So they are all included as .dll files with the tooling. So if you look in your temp folder, you’ll find an EFPT version number something something. And that is where all the magic takes place from the Visual Studio extension.
Jamie : [51:31] Right. And so is that how the CLI works as well? So essentially, is the magic being performed the same way via the CLI?
Erik : [51:44] In the CLI, you actually have to explicitly install a version for the version of EF Core you’re targeting. You have to specify a version number or a version wildcard anyway when you’re installing it. So, “I want to install a CLI for EF Core 8,” for example, or EF Core 7 or EF Core 6.
Jamie : [52:06] Right. Interesting. Interesting.
Erik : [52:10] So because you can’t run multiple .NET framework versions at the same time.
Jamie : [52:17] Yes.
Erik : [52:18] Right.
Jamie : [52:19] Yeah, that was the big, or rather one of the big innovations with modern .NET, wasn’t it? Or .NET Core, as it was called at the time. That side-by-side installation that you could install and, technically, run different versions at the same time.
Erik : [52:37] Long as you have the runtime installed yeah.
Jamie : [52:39] Sure.
Jamie : [52:40] Okay, so if i’m looking at a project and it’s a .NET 7, because that’s kind of still in support, so i’m using .NET let’s say i’m using .NET 7 it’s different more core 7 uh no .NET 6 let’s go .NET 6 because that one definitely still in support at the time of recording; so i’m building an app let’s say with .NET 6, EF Core 6, I can just if i’m on a mac or one the Linux-on the-desktops, or maybe i’m just on Windows and I like using the CLI; I can grab a version of EF Core Power Tools that targets .NET 6 and EF Core 6, and I can just do whatever I need to do. My app then gets upgraded to .NET 8, EF Core 8, perhaps even .NET 9, EF Core 9 when it comes out later this year. I just grab the CLI version for that version of .NET, and then just it continues to perform its magic, right?
Erik : [53:34] Correct. Correct. Yeah, so then you just need to explicitly install the newer version, yes.
Jamie : [53:42] Right. I like that. Nice.
Erik : [53:45] The alternative was publishing specific named versions for each .NET version. So I could publish something called ErikEJ.EFCorePowerTools.Cli.6, and .7, and .8.
Jamie : [54:07] Yes.
Erik : [54:09] I don’t know.
Jamie
:
[54:10] I thinkthe version system you have already is is way better than thatust because then it’s I don’t know that to me, being able to supply a version string or a version wildcard string or something like that, an identifier, rather than saying, “oh what was it was it it was is it dot EF Core six or is it dot EF Core seven or is it dot EF Core 8?” That I feel like is is a little bit more taxing on the developer than just saying you know dotnet install –version 8
or whatever the string is right. That makes way more sense to me.
Erik : [54:48] I think it’s just 8.* or something like that. But it it’s my documentation , like, “how do I get the latest version?” yeah.
Erik : [54:59] Excellent.
Jamie : [55:00] So I guess, as we’re starting to run out of time here, I was just wondering if someone wants to get started with using EF Core Power Tools—let’s just assume for this moment in time that folks are using Visual Studio—if someone wants to get it get started with using EF Core Power Tools, how do they get started? Is it just go to the repo and click a button, and download it, and success?
Erik : [55:27] They can install it from the extension manager in Visual Studio; it should be relatively self-explanatory. But otherwise in the wiki I have like a welcome page with a like a one one pager getting started kind of pit of success thing: pick their database, pick your objects, click okay, and and run along. I think my mantra for creating things like these tools is, “should be easy to get started and there should be a like an easy happy path but then if you want to deep dive and do a lot of options or even a t4 templates you can also do that,” but there should be a simple happy path with good error reporting if something fails.
Jamie : [56:26] Okay yeah and I have to I have to say that um when I when I started using EF Core Power Tools and it was you know um october november 2022 so you know not that long ago at 2023 sorry 2023 not that long ago I found the that wiki getting starting guide really useful it is quite literally are you in Visual Studio are you targeting this version of the entity framework are you working with SQL Server, okay, push this button, and it’s brilliant.
Erik : [56:59] Yeah, and off you go, yeah.
Jamie : [57:02] Excellent. What about then getting in touch with you or keeping up with development of EF Core Power Tools? What’s the best way for folks to do that?
Erik : [57:12] I always welcome people reaching out to me on GitHub, and I know it’s called “issues, " but just thinking, I’m more thinking about it as a communication channel that for anything that relates to EF Core Power Tools: feature proposals, suggestions, bug fixes, bug suggestions, whatever. I’m also on Twitter. So, Eric EJ on Twitter, or what is now called X. So, people can also reach out to me there, but I think it’s often more fruitful to have a written conversation and GitHub issues are a really good medium for that.
Jamie : [57:59] I agree. I agree. Because then, like, if there is a conversation that needs to happen and it eventually turns into some work that needs to be done, like a pull request or something, you can refer directly to the issue from within GitHub, right? It makes it so much easier to keep sort of a log of everything.
Erik : [58:18] Exactly.
Jamie : [58:19] Amazing. Amazing. well it has been absolutely wonderful talking to you today o I want to thank you for being on the show and i’m sure the listeners will be thanking you too. But yeah I really appreciate it thank you ever so much.
Erik : [58:35] You’re welcome Nice speaking to you.
Jamie : [58:40] Brilliant, thank you.
Wrapping Up
Thank you for listening to this episode of The Modern .NET Show with me, Jamie Taylor. I’d like to thank this episode’s guest for graciously sharing their time, expertise, and knowledge.
Be sure to check out the show notes for a bunch of links to some of the stuff that we covered, and full transcription of the interview. The show notes, as always, can be found at the podcast's website, and there will be a link directly to them in your podcatcher.
And don’t forget to spread the word, leave a rating or review on your podcatcher of choice—head over to dotnetcore.show/review for ways to do that—reach out via our contact page, or join our discord server at dotnetcore.show/discord—all of which are linked in the show notes.
But above all, I hope you have a fantastic rest of your day, and I hope that I’ll see you again, next time for more .NET goodness.
I will see you again real soon. See you later folks.
EF Core Power Tools Contributors
The following list is correct as of Oct 4th, 2024, and aims to show that it takes a village to create a tool as ubiquitous as EF Core Power Tools. It contains the top 10 (arranged by number of contributions) devs who have worked on EF Core Power Tools.
- Erik Ejlskov Jensen
- Stephan Over
- Varorbc
- Will 保哥
- Pedro Rocha
- P. León
- Pratik Pote
- Emanuele Curati
- Jonathon Wyza
Useful Links
- EF Core Power Tools wiki
- EF Core Power Tools on GitHub
- Install EF Core Power Tools as a .NET global tool
- XKCD: Dependency
- DacFx
- MSBuild.Sdk.SqlProj
- Episode 19 - The .NET Foundation with Jon Galloway
- Connect with Erik on GitHub
- Connect with Erik on X
- Erik’s blog
- Supporting the show:
- Getting in touch:
- Music created by Mono Memory Music, licensed to RJJ Software for use in The Modern .NET Show