TRANSKRİPT 🔗
WEBVTT
00:00:00.320 --> 00:00:04.959
Every technology, framework, and feature in software development has a drawback.
00:00:05.200 --> 00:00:12.880
That's the reason why we have so many options, and it's why it depends is such a common approach to any question.
00:00:13.039 --> 00:00:15.279
And software development is always changing.
00:00:15.439 --> 00:00:22.000
So we need to constantly evaluate what worked yesterday and see if it still works as well today.
00:00:22.239 --> 00:00:33.280
In this episode of Dev Questions, I want to start the conversation around ORMs and if they're even necessary anymore in light of AI-empowered development.
00:00:41.200 --> 00:00:44.960
Welcome to the DevQuesti podcast with Tim Corey.
00:00:45.280 --> 00:00:48.079
Software development is more than just writing code.
00:00:48.240 --> 00:00:50.000
So let's talk about the rest of it.
00:00:50.240 --> 00:00:56.560
Specifically, let's talk about if Entity Framework is still relevant to modern software development.
00:00:56.799 --> 00:00:59.359
Now, this episode is a bit different than normal.
00:00:59.520 --> 00:01:03.280
I want to talk through with you what I've been working through personally.
00:01:03.439 --> 00:01:08.879
I don't think this subject is decided yet, nor do I think there's one clear answer for everyone.
00:01:09.040 --> 00:01:20.879
However, I do think the landscape is shifting, and I want to use this as an opportunity to help you work through your own decision-making process around AI and development in general.
00:01:21.040 --> 00:01:24.799
So let's start with a baseline understanding of entity framework.
00:01:25.040 --> 00:01:34.400
Now, it was designed to reduce TSQL by saying, hey, if you write a model in C sharp, just say that model is now on my table.
00:01:34.640 --> 00:01:37.920
And that reduces the TSQL you have to write.
00:01:38.239 --> 00:01:46.719
It makes database it makes database development faster at the expense a bit of the speed in production.
00:01:47.359 --> 00:01:51.120
Now, it accomplished this with a lot of generated code.
00:01:51.439 --> 00:01:58.799
And it can be abused by developers who think they don't need to know SQL if they use Entity Framework.
00:01:58.959 --> 00:02:00.799
So I'm gonna be careful here.
00:02:01.040 --> 00:02:03.840
Entity framework is a great tool.
00:02:04.159 --> 00:02:06.480
It is also abused a lot.
00:02:06.640 --> 00:02:13.439
Okay, so there is a bit of a, you know, a little bit of column A, a little column B in any of these decisions.
00:02:13.759 --> 00:02:23.759
Now, if you want to boil it down to its essence, entity framework is supposed to make your development experience faster at the expense of runtime performance.
00:02:23.919 --> 00:02:30.240
And again, to be clear, I'm not saying it makes your runtime performance terrible unless you abuse it.
00:02:30.400 --> 00:02:34.719
But it is gonna be a little bit slower than if you didn't use Entity Framework.
00:02:34.800 --> 00:02:36.080
It's
Load full transcript
got overhead.
00:02:36.319 --> 00:02:42.240
Now, as you probably know, personally, I like I like to use Dapper, which is a micro ORM.
00:02:42.319 --> 00:02:42.560
Okay.
00:02:43.199 --> 00:02:45.039
I still like to write the tSQL.
00:02:45.280 --> 00:02:47.120
Um I still have to do it myself.
00:02:47.360 --> 00:02:54.240
The I think the TSQL is pretty easy to write because I'm a SQL developer.
00:02:54.400 --> 00:03:00.960
But also TSQL is easier to debug when it's in the database as opposed to ad hoc queries.
00:03:01.280 --> 00:03:03.680
Um I still have to maintain the database project.
00:03:03.840 --> 00:03:14.800
If you don't know, there is a database product type in Visual Studio or in.NET that you can then maintain your SQL project in and do things like refactoring, et cetera.
00:03:14.879 --> 00:03:21.919
But I still have to maintain that additional project as opposed to entity framework where that generated code does it for me.
00:03:22.240 --> 00:03:28.719
Now, every data call that I make, I have to write a query for, or at least have a query that will stand in for that.
00:03:28.800 --> 00:03:31.520
I may have three or four calls that use the same query.
00:03:31.759 --> 00:03:45.680
To boil it down to its essence, Dapper makes my runtime performance faster at the expense of development performance, which is why I have always landed mostly on the side of using Dapper.
00:03:45.840 --> 00:03:51.919
I don't mind spending a bit of extra time in development to make my runtime performance faster.
00:03:52.240 --> 00:03:58.240
Now, now we have an understanding of these two options, I think it's time we ask some questions.
00:03:58.400 --> 00:04:02.639
Uh, number one, why is Entity Framework less performant?
00:04:03.120 --> 00:04:05.680
And this comes down to assumptions.
00:04:05.840 --> 00:04:07.520
It's really what it comes down to.
00:04:14.000 --> 00:04:22.639
And so when you say, I have a model that has string first name, string last name, it doesn't know how big are those strings.
00:04:22.879 --> 00:04:26.079
Should they be 100 characters, 200 characters, 300 characters?
00:04:26.240 --> 00:04:26.879
We don't know.
00:04:27.120 --> 00:04:40.480
And so it does things like create Nvarchar Max fields for every string field, unless you specify a size, which makes sense when you think about it, because it doesn't know what size your string might be.
00:04:41.040 --> 00:04:50.959
Those decisions, along with a number of others that can kind of pile on top of those, can cause overhead.
00:04:51.120 --> 00:04:56.240
They can cause your application to run slower, your database to run slower, queries to run slower.
00:04:56.399 --> 00:05:07.600
Now, yes, you can write better EF models where they say exactly how many characters and what data type it should be for a string type, et cetera.
00:05:07.839 --> 00:05:17.839
You can do a lot more work in C sharp to make sure that Entity Framework has all the information it needs so it doesn't have to
make an assumption.
00:05:18.160 --> 00:05:20.800
The problem is that it takes a lot of work.
00:05:20.959 --> 00:05:29.199
And that lot of work really reduces how much value you get out of entity framework, making your job easier.
00:05:29.519 --> 00:05:29.839
Okay.
00:05:30.079 --> 00:05:34.000
There's also just the overhead of it has to run a lot of code.
00:05:34.160 --> 00:05:42.480
There's a lot of code that has to run in order to build those queries, in order to send those queries across the wire, in order to get the data back.
00:05:42.720 --> 00:05:53.360
If you're not careful, then you can have a lot of duplicate, duplicate data come across the wire be so they can reconstitute that into a uh a nested model.
00:05:53.600 --> 00:05:59.519
Now there's ways, again, to make that more efficient, but again, you have to know more about entity framework.
00:05:59.759 --> 00:06:03.120
But that's that's some of the reasons why entity framework is less performant.
00:06:03.360 --> 00:06:14.800
There's just the pure overhead of it's writing more code and also a lot of assumptions in your code that it has to make because it doesn't know unless you're really careful to specify everything.
00:06:15.120 --> 00:06:18.399
So why is Dapper development slower?
00:06:18.720 --> 00:06:30.800
Well, when you're writing a store procedure or a query by hand and then trying to keep those in sync every time you make a change, especially during the early development process, once you've kind of locked things in, it's a whole lot easier.
00:06:30.959 --> 00:06:35.040
But when you're first developing, you're like, well, I think I'm gonna need first name, first name, and last name.
00:06:35.120 --> 00:06:43.360
So I'll create the table that has first name and last name, and then I'll create the store procedures for all the cred actions, you know, create, read, update, and delete.
00:06:43.439 --> 00:06:47.279
And then you go, hmm, I actually need first name, middle name, and last name.
00:06:47.439 --> 00:06:47.680
Okay.
00:06:47.839 --> 00:06:53.920
So I change a table, I change the the model, I change um every one of those store procedures.
00:06:54.079 --> 00:06:55.600
And now you go, okay, is that enough?
00:06:55.759 --> 00:07:00.160
And that's where the development process can be slower.
00:07:00.720 --> 00:07:04.480
So is there a way we can meet in the middle?
00:07:04.720 --> 00:07:12.079
So you get, I want the development speed of entity framework with the production speed of Dapper.
00:07:12.319 --> 00:07:14.480
So the question is, can we get there?
00:07:14.639 --> 00:07:18.879
And I think the answer is yes, with AI assisted development.
00:07:19.040 --> 00:07:27.839
Now, some of you may have just cringed all over the place because I said AI in reference to your database, and you just got terrified.
00:07:28.079 --> 00:07:31.839
And there can be a good reason why you're terrified.
00:07:32.079 --> 00:07:38.800
Because, yeah, if if you are thinking about letting an AI loose in your database, don't do that.
00:07:38.959 --> 00:07:41.759
That's scary, that's dangerous.
00:07:42.079 --> 00:07:44.000
But I'm not talking about that.
00:07:44.160 --> 00:07:47.759
I'm also not talking about telling the AI, just figure it out.
00:07:47.920 --> 00:07:50.079
Again, assumptions, not a good thing.
00:07:50.240 --> 00:07:59.120
But if you say, hey, I've built the database, AI, can you turn these tables into C sharp models?
00:07:59.360 --> 00:08:06.480
Super easy to do, low cost, you know, local models can do this very easily.
00:08:06.720 --> 00:08:16.879
So now all of a sudden, the the advantage of, well, I can do database first development with Entity Framework and have it create the models, I can do that with AI.
00:08:17.199 --> 00:08:23.439
Only they're more efficient because of the fact that it's specific, no assumptions.
00:08:24.000 --> 00:08:31.519
Now, if you build them out the models in C sharp, an AI can turn your models into efficient SQL tables.
00:08:31.920 --> 00:08:36.559
And it can also create queries based upon what data you need.
00:08:36.720 --> 00:08:47.120
And if you change your model, an AI can update your tables and the associated views and store procedures if you even need that, because we also have a database project that can do refactoring, et cetera.
00:08:47.440 --> 00:08:52.159
But with AI, we can do some of this boilerplate stuff.
00:08:52.320 --> 00:09:06.240
And this is where I think AI can really be a big benefit when it's assisting you, not leading, assisting you, because all of a sudden now you're allowing it to say, hey, here's your very strict requirements.
00:09:06.559 --> 00:09:07.759
Go do this thing.
00:09:07.919 --> 00:09:09.120
And you just need to check it.
00:09:09.279 --> 00:09:10.159
That's it.
00:09:10.639 --> 00:09:18.240
So you, in my opinion, user experience is an incredibly important part of a success of an application.
00:09:18.480 --> 00:09:32.720
I've known organizations that have spent thousands of dollars per month in cloud resources just to throw resources at a poorly tuned entity framework system that they just couldn't tune anymore, it felt like.
00:09:32.960 --> 00:09:37.279
And they're just trying to get some type of performance out of it.
00:09:37.360 --> 00:09:44.639
And they're trying to overcome that poor performance that was baked into the code by just throwing more resources at it, more money.
00:09:44.879 --> 00:09:55.519
And that gives your users a bad experience because it's still slow and it crashes a lot or it's you know, it's taking a lot of resources, but it also increases the cost to your company.
00:09:55.759 --> 00:10:07.759
By utilizing AI effectively, I think we can reduce the use of ORMs like Entity Framework, which allows us then to reduce costs and increase customer satisfaction.
00:10:07.919 --> 00:10:10.159
We can kind of have the best of both worlds.
00:10:10.559 --> 00:10:15.679
So this allows us to say, hey, I want some
of that generation ability.
00:10:15.840 --> 00:10:28.320
But instead of trying to use code generators, which have to make broad assumptions from the factory essentially, um, Microsoft writes these code generators to work in the broadest number of circumstances.
00:10:28.639 --> 00:10:34.320
Your AI assistant is building based upon your specific needs.
00:10:34.720 --> 00:10:44.080
And so it's very much more uh focused on you and less the generic, we hope this works for most people.
00:10:44.240 --> 00:10:48.559
And it's very specific to this should work for your specific case.
00:10:48.799 --> 00:11:05.759
So all of a sudden we have that same code generation, but instead of it being entity framework and boilerplate code and a lot of generated code that really we have to support, even though we didn't write it, and we might not even look at the code, which we've been doing that for years before AI.
00:11:05.840 --> 00:11:15.120
Uh instead of doing that, we can actually use AI to help us use a faster tool like Dapr, or even just go ADO.net if you want.
00:11:15.279 --> 00:11:22.000
Although I think that Dapr provides enough tooling in that micro part without providing a whole lot of overhead.
00:11:22.080 --> 00:11:23.519
Um, I think it's worth it.
00:11:23.759 --> 00:11:34.960
But but even so, you can have this micro ORM that accesses our database very, very efficiently while at the same time not adding to our development experience.
00:11:35.279 --> 00:11:41.200
So while ORMs like Entity Framework are a big target, I don't think we should stop there.
00:11:41.519 --> 00:11:54.960
Now, I would like you to think about how you can make um something better, more efficient in your software by using AI or using the new ways of doing things.
00:11:55.279 --> 00:12:03.039
So not just saying, hey, we've done this for years, that's the way we're gonna do it going forward, but thinking, hey, how can you be more efficient?
00:12:03.200 --> 00:12:16.480
How can you provide a better product for customers at a cheaper price, at a more, you know, a faster turnaround without creating AI slot, without creating unmaintainable code.
00:12:16.639 --> 00:12:17.919
I'm not advocating for that.
00:12:18.080 --> 00:12:20.320
In fact, I'm advocating against that.
00:12:20.799 --> 00:12:26.799
But just because you can abuse something doesn't mean there isn't a place for it.
00:12:26.960 --> 00:12:33.360
Kind of like how entity framework can be abused, that's not to say there wasn't a place for it.
00:12:33.759 --> 00:12:44.399
But I think when we talk about AI and think about the new ways of doing software development, I think we need to think through how do you make this process better for everybody?
00:12:44.720 --> 00:12:53.600
So we want to create better software based upon wise decision making that does adjust with the times because the times are changing.
00:12:53.759 --> 00:13:01.600
And if we just stay where we're at, we're gonna get left behind, like every generation before us that has done the same thing.
00:13:01.840 --> 00:13:03.840
So we need to think about adjusting.
00:13:03.919 --> 00:13:20.240
We need to think about, hey, where can we make things better and more efficient with these new ways of doing things without losing who we are, without making a poorer product, without making a messy product or a slop product, but instead making a more efficient product that's better for our users.
00:13:20.480 --> 00:13:20.879
All right.
00:13:21.120 --> 00:13:22.080
Thanks for listening.
00:13:22.320 --> 00:13:24.399
As always, I am Tim Corey.
00:13:24.879 --> 00:13:27.840
Thank you for joining us for this episode of Dev Questions.
00:13:28.000 --> 00:13:36.320
When you're ready to learn to think and code like a professional developer, head over to imtimcorey.com and enroll in a course.