Dapper v/s Entity Framework(Core) - .NET Interview Question

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] do i use dapper or entity framework for my.net project it is always confusing when you have to make a decision hi guys and welcome to dot net mastery my name is brugin and if you love content related to dart net programming make sure to subscribe to the channel that way you will always be notified when i publish new videos now let's get back to the big question entity framework core or tapper most common answer that you hear is it depends but what does it really depend on that is what we will answer in this video first let me take a quick overview dapper is a micro orm in simple words it is an object mapping tool which helps to map results from a query to the domain classes or models in c-sharp and that is the main functionality of a micro orm entity framework core on the other hand is a full-fledged orm framework for net application it does the mapping like dapper but it does much more since it is a complete framework it allows developers to work with everything in database using.net domain classes in simple words if you use entity framework or entity framework core then you do not have to write queries to create read update or delete a record orm is responsible to do all of that with few lines of code now let's take a look on what is preferred in which scenario dapper is preferred by company's word database first what i mean by that is companies who have dbas or developers who loves to write their sql statements with dapper you will have full control on the sql and it will not be abstracted like in case of entity framework entity framework on the other hand is preferred where developers love to code in c sharp and they do not want to worry about the sequel entity framework team does an amazing job at making sure the sequel that gets executed behind entity framework is optimized and sometimes it would even be more optimized than if a developer was writing query themselves so kudos to entity framework team for that when it comes to performance dapper is typically faster than entity framework whether we use tracking or not basically if your application is extremely sensitive to performance then i would vote for tapper hands down but honestly that much sensitivity to performance is a rare scenario on the other hand if your company is more focused on productivity then entity framework core will win the race with entity framework core transactions and rollbacks are automatically managed everything is in source control and you can easily revert back to old version of migration that are applied to the database and view what exactly was modified with great power comes greater responsibility when we work with entity framework core developer needs to know migration how to read them and what happens if migrations get corrupt they should also be familiar with how db set chainsat and db tracker works it will not be a good scenario if someone starts with entity framework core only with the basic knowledge so tapper has an easier learning curve since developer would write sql as compared to entity framework lastly when it comes to dotnet executing stored procedures working with views it is much easier to do that with dapper than working with entity framework now this might change in future but as of dotnet 7 stored procedures are much easier with dapper having worked with both dapper and entity framework if i had to pick one for my team who is well experienced in both dapper and entity framework i would still not blindly pick one for my team if my project contains complex read operation and it is performance critical then i would lean towards dapper else i would be in favor of entity framework i have also worked with project that uses tapper for data retrieval because of the stored proc flexibility there and entity framework core for everything else and that project also worked flawlessly so that could be another route that is possible but i would lean towards picking one and then if situation arises where it is not working optimal only then i would go with the hybrid route if you want to learn more about tapper or entity framework code in depth you can check out more on.net mastery i hope my experience with dapper and entity framework helps you to make the right choice if you enjoyed this video make sure to like the video and leave a comment if you have any questions or if you have other topics that you want me to cover in the next video
Info
Channel: DotNetMastery
Views: 21,027
Rating: undefined out of 5
Keywords:
Id: ialFGpKD8yI
Channel Id: undefined
Length: 5min 44sec (344 seconds)
Published: Mon Sep 12 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.