You may be aware of another pattern that's been around since the beginning of EF, and which continued through EF Core, and that's that INSERT commands have always been paired with a SELECT to return the database-generated value of any primary or foreign key. This is a great example of the types of tweaks made to the updates.Īnother tweak is related to inserts. Granted this was only a change from about 8 ms to 4 ms, but those do add up in a production application. And when comparing EF Core 6 to EF Core 7 where the database was on a remote server, Shay measured a 45% improvement on the SaveChanges call. Therefore, when SaveChanges involves only a single change, rather than sending the three commands (BEGIN TRANSACTION, the change command, and then COMMIT), EF Core 7 only sends the change command, cutting the chattiness down from three commands to one. If you only have one command being sent, the calls for the transaction aren't needed because there aren't other commands involved. As you may know, EF Core wraps every command sent in SaveChanges inside a database transaction so that if one fails, they'll all roll back. An interesting one is a drawback of EF Core's default transaction behavior. Some of Shay's discoveries were nuances that I hadn't paid attention to. However, if you do want to geek out on these changes, I highly recommend watching the standup video here on YouTube ( ). Each tuning may have only sped things up a small amount, but they do add up!Īlthough most of these tweaks are under the covers and you will benefit from them without having to take any action, I would like to highlight some of them for you. In an EF Core Community Standup earlier this year, Shay walked us through a fascinating look at the discoveries he'd made and the tunings he applied. Some of the inefficiencies he discovered hailed back to the early days of Entity Framework. Shay Rojansky, who has become “the performance guy” on the EF team, has explored the many nooks and crannies within SQL sent to the database and other related areas, discovering many points at which efficiencies could be applied. And true to their word, there was a lot of work done on updates that EF Core sends to the database. At that time, the team committed to focusing on improving the performance of other workflows in EF Core 7. Faster and Faster!īack in 2021, one of the biggest stories for EF Core 6 was the dramatic performance improvement for non-tracking queries. So, I may wait until EF Core 8 to use the new nickname. I still remember that first version of EF Core, just after EF6, which had a working name of EF7 until it became EF Core. You'll find this article filled with some of the features that will be most impactful to the bulk of dev teams as well as a few that I personally found interesting.Īlthough I will always refer to this version as EF Core 7, keep in mind that much of the documentation and other resources will use EF7 as its nickname. Not only does it mean writing about them, but I also get to test them all out, which is quite a lot of fun, thanks to the fact that I don't have to do so with the goal of releasing production code. I've been overwhelmed in trying to choose which of its features to share with you here. So you can continue using it on a supported version of. NET 6, which is the long-term support version of. Although EF Core 7 is being released alongside. That has a lot do with the fact that the team has made a big investment in creating a stable base to build on. For this purpose, we like to use Postman, but feel free to use any client of your choice.Lately, it seems that each iteration of EF Core brings fabulous new features and improvements. Let’s use our POST method to insert some data into the database. This is a simple controller, and all it has is three methods: Return CreatedAtRoute(nameof(GetById), new, student) Public IActionResult Post( Student student) NET/C# content and get paid? > JOIN US! (Guid.Parse(id)) Wanna join Code Maze Team, help us produce more awesome. Then, we’re using the NpgsqlConnectionStringBuilder to build our PostgreSQL connection string, and finally, connect ApplicationContext to the database using that connection string. We are populating the connection string and password from the configuration file.ĭon’t do this for real-world projects, use secrets mechanism and environment variables instead. NET/C# content and get paid? > JOIN US! (options => options.UseNpgsql(builder.ConnectionString)) Īside from the AddMvc() method, everything else is what we need to configure our database.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |