You are making so developers' life easier! While in this world, everything has a price, you are spreading valuable knowledge free. You are just awesome!
Hello Ron - Wow....Hearty Congratulations. Very happy for you. Thank you very much for taking time to share the good news. It's an honour. Good luck and all the very best with your new role.
This is by far the best explanation of the Repository pattern on the freakin' Internet to date, when I say far I mean like the distance from the MIlky Way to the end of the Universe far. Mate... great job keep it going.
Hello Marko - Thank you very much for taking time to give feedback. This means a lot. I am very glad you found the videos useful. Good luck and all the very best with everything you are doing.
This is height of coincidence ! ,..I was just going through few youtube videos about repository pattern ,but was not satisfied with their explanation .I was thinking in my my mind ,i wish kudvenkat could have uploaded video on same topic ...and allas! video poped up in my recommendation with uploaded time 7 minutes ago
It's a really amazing and simple explanation. Thanks a lot Kudvenkat. I regret taking a course at Naresh IT, Hydrabad. They wasted my time and money. Thanks again Kudvenkat.
I did seen many videos to understand the loosly couple feature of dependency injection. I found the exact loosly coupling example in this.also, i did watch your other videos in learn dotnet core section.every one is awsome. Thanks you sir for the nice videos..
The moment you call dbContext.SaveChanges() after calling Remove(employee), the employee record will get deleted from the database. But you still have a reference to the corresponding employee object. You can use that for logging etc.
Thank you so much for all your efforts, the description is also so informative , which proves your complete dedication that too for free, Really thank you sir , following you since college , my all major minor projects are becoz of you.
Hello Shruti - Thank you very much for the feedback. Means a lot. I have included all the ASP .NET Core tutorial videos, slides and text articles in sequence on the following page. Hope you will find it handy. www.pragimtech.com/courses/asp-net-core-mvc-tutorial-for-beginners/ When you have some time, can you please leave your rating and valuable feedback on the reviews tab. It really helps us. Thank you. Good luck and all the very best with everything you are doing.
Hi Venkat, Great explanation. I have one question regarding AddScoped. What will happen if I use AddSingleton instead of AddScoped? I know the difference between them but I did not understand the real time benefit of using AddScoped in this video.. What is the advantage of using AddScoped? Can you please explain? Thanks
I have a question, at 05:17 We are coping properties of employeeChanges to employee, but employee already equals to employeeChanges at line 51, why should we copy the properties again?
Thank you so much Venkat. You have really done well. I have a question. If we have 100+ repositories, are we suppose to list all of them in the ConfigureServices Method? That I feel might be difficult to manage. Your advice please. Thank you
Of course! Onion architecture explained by Mr Venkat will be very easy to understand as he knows how to bring difficult contexts simple and clear. Thanks to him for help developers.
Nicely explained but it seems similar to video on DI. Again the same doubt how one can have reference of multiple store repository at the same time, in this case InMemory and SQL repositories and use one on the fly as per requirement?
I am getting this exception, whats wrong with me? InvalidOperationException: The DbContext of type 'AppDbContext' cannot be pooled because it does not have a single public constructor accepting a single parameter of type DbContextOptions.
Some people say that Repo pattern over EntityFramework is antipattern. EntityFW is already repository. Also not sure if .Save() inside of each repo method is good idea. What if you need to do few entity operations during request - then it will be few DB transactions. Probably better to have BaseRepo where you do generic retrival, update, create and save operations.
hi venkat, one question in realtime scenario will use only with one databse(SQl,Oracle,..) we don''t need to create repositories multiple, Then how this repository pattern useful.
Seperation of concerns. Back in the days when we were using ADO, we also created a data access layer that gets data from SQL and pass back to the caller which is the business logic layer. I see this repository pattern is pretty much doing the same thing.
sorry sir,i dont think repository pattern is neccesary.We 've created the dbContext instance by depency injection,why not just use the methods of our appDBContext to access the database in the controller action method?
A lot of the topics that Venkat teaches may seem unnecessary in small projects. But he's preparing you for when you go into larger and complex projects. Having a repository class ensures you retrieve data the same way everytime, as you may require the same data from more than one business logic layer components.
Why would we need a repository? Can't we directly implement those CRUD methods in a service? Like EmployeeService which has a readonly private AppDbContext to work with? Why add another layer (repository)? Or am I just mistaking naming conventions and in this video Repository is a sort of Service?
I'm getting a red squiggley line in the following code Department = Dept.HR in the MockEmployeeRepository. Should I have some Properties in the Department Class? Thanks !
Thank you so much for this amazing tutorial, For people using API, to display the result, use the following code in controller: [HttpGet] public IActionResult Get() { var employees = _employeeRep.GetAllEmployee(); return Ok(employees ); }
I am not getting error cannot open databse . I am getting the error Object reference not set to an instance of an object. @foreach (var employee in Model). Please help me on the same.
Not sure if this has already been answered or not, but if you do AddSinglton an exception will be thrown: Singleton ImplementationType: EmployeeManagement.Models.SQLEmployeeRepository': Cannot consume scoped service 'EmployeeManagement.Models.AppDbContext' from singleton 'EmployeeManagement.Models.IEmployeeRepository
So not this one ( video and tutorial) is great, all your videos are, but when one tutorial with Data Access and stored procedures , for those who has already databases ,stored procedures, triggers..etc? Thanks
Hello Sir HTTP Error 500.30 - ANCM In-Process Start Failure I got this error while running the project, how to fix this ? As I have done the same things that you have done in the project so far. Please Reply as soon as possible
If you have problems running the pogram it might be because you don't have the default page as index just put app.UseMvcWithDefaultRoute(); before app.UseMvc(routes => { routes.MapRoute("default", "{controller=Home}/{action=Details}/{id=2}"); }); and it should work (version 3.1)
You will hit an error if you use AddSingleton. This is because internally services.AddDbContext adds the context as a scoped service and you can't use a scoped service inside a singleton service. Singleton service - Instance created on first request, stays alive and shared by all users until the application shuts down. Scoped service - Instance created on first request of a web request, stays alive and used only by the same web request. So why is the dbcontext added as scoped instead of singleton? Because * We would not want to have a dbcontext service to be shared by multiple users. * If it is a singleton service, it will stay alive and keep using more and more system resources for the hundreds and thousands or even millions of database calls and will soon crash the application.
You are making so developers' life easier! While in this world, everything has a price, you are spreading valuable knowledge free. You are just awesome!
this is youtube marketing bro, this video won't teach you anything, but it will make you interested in buying his course
@@newageeducation5908 It's teaching us a lot.
@@newageeducation5908 Wrong. His youtube videos are some of the best resources on the internet.
@@newageeducation5908 The content and knowledge Venkat gives in his course for free, that, others charges 100s of bucks for the same.
@@newageeducation5908 bro urs wrong assumption. Pls remove ur assumption . his video's helped a lot. It's free of cost.
When I have a headache in coding I will come to Venkat clinic!!!
Venkat is an awesome teacher. Easy to understand and all his material is very practical. He's almost always my go to source.
I learned a lot from this Video Series and I have a new job right now, thank you man !
Hello Ron - Wow....Hearty Congratulations. Very happy for you. Thank you very much for taking time to share the good news. It's an honour.
Good luck and all the very best with your new role.
Nice dear God bless
me too.
This is by far the best explanation of the Repository pattern on the freakin' Internet to date, when I say far I mean like the distance from the MIlky Way to the end of the Universe far. Mate... great job keep it going.
Hello Marko - Thank you very much for taking time to give feedback. This means a lot. I am very glad you found the videos useful.
Good luck and all the very best with everything you are doing.
This channel never fails to disappoint me. Learned C# from 2013 with Kudvenkat. Thank you very much! and more power!
Most clear and simple lecture on repository pattern i have came accross. Thank you sir. Love & Respect.
Its Insane how good this thing is i love Venkat man :D
This is height of coincidence ! ,..I was just going through few youtube videos about repository pattern ,but was not satisfied with their explanation .I was thinking in my my mind ,i wish kudvenkat could have uploaded video on same topic ...and allas! video poped up in my recommendation with uploaded time 7 minutes ago
I'm learning lot of technology things from your tutorials... Really superb...
Great video to learn if you are new and refresh the knowledge if you are old developer.
Excellent! Very concisely describes how and why to use the repository pattern!
Best explanation I have seen so far
It's a really amazing and simple explanation. Thanks a lot Kudvenkat. I regret taking a course at Naresh IT, Hydrabad. They wasted my time and money. Thanks again Kudvenkat.
Waiting for the next video to be uploaded. The explanations here are SUPER AWESOME! Thank you very much for making such great tutorials.
Great❤❤❤
wow...just wow...you are truly amazing!! What a gem. God bless you
Thanks for sharing knowledge
Nice Video. Thanks Sir
Thank you for saving my career
very informative , concentrated and clear . If I can give more than one like I will give million likes, THANKS A LOT HERO
It is such a clean, clear and up to the mark explanation
thanks very very much, please continue
Thank you for the awesome video.
I need to find out special word to say thank you...!!!☺️
very informative vid, great job!!
Thank you for the video. very useful
Very Nicely Explained the concept. Thank You ...!!!
I did seen many videos to understand the loosly couple feature of dependency injection. I found the exact loosly coupling example in this.also, i did watch your other videos in learn dotnet core section.every one is awsome. Thanks you sir for the nice videos..
Hello Ashique - Thank you very much for taking time to give feedback. This means a lot. I am very glad you found the videos useful.
As usual, another useful video from kudvenkat. But one question -
8:42 - Return the deleted employee? How is that possible?
The moment you call dbContext.SaveChanges() after calling Remove(employee), the employee record will get deleted from the database. But you still have a reference to the corresponding employee object. You can use that for logging etc.
Damn, outstanding tutorial
Thank you
very helpful and nice explanation sir.
Really good explaination. Thank you very much !!!
Your videos are very useful, thanks. Your diction is excellent!
Great video!
Clear explanation of the repository pattern. Thank you Venkat. 👍
Thank you so much for all your efforts, the description is also so informative , which proves your complete dedication that too for free, Really thank you sir , following you since college , my all major minor projects are becoz of you.
Hello Shruti - Thank you very much for the feedback. Means a lot. I have included all the ASP .NET Core tutorial videos, slides and text articles in sequence on the following page. Hope you will find it handy.
www.pragimtech.com/courses/asp-net-core-mvc-tutorial-for-beginners/
When you have some time, can you please leave your rating and valuable feedback on the reviews tab. It really helps us. Thank you. Good luck and all the very best with everything you are doing.
Really sir you are awesome!
Thank you for this!
great trainer thanks thanks thanks :)
It would be great to have some videos in this playlist about unit testing with the IEmployeeRepository registry.
Hello Venkat,
Your all videos are excellent & easy to understand. Can you make video on "Unit Of Work" Pattern with example.
Thank you for the upload
Amazing videos @kudvenkat Used this to help me complete some of the implementation for my dissertation.
Marvelous!
Any video reference to understand the concept of generic repository and Unit of Work pattern. Thanks
Hi Venkat,
Great explanation. I have one question regarding AddScoped. What will happen if I use AddSingleton instead of AddScoped?
I know the difference between them but I did not understand the real time benefit of using AddScoped in this video.. What is the advantage of using AddScoped?
Can you please explain?
Thanks
if you know the answer tell me?
Same question :/ Can anyone help for future viewers?
excellent
I have a question, at 05:17 We are coping properties of employeeChanges to employee, but employee already equals to employeeChanges at line 51, why should we copy the properties again?
Why would you not use a singleton for the IEmployeeRepository? Thanks.
Thank You Sir :)
Thanks buddy
Thank you sir ji
Hi Mr. kudvenkat can you make videos on angular 7 and asp.net core web api implementation.
Thank you so much Venkat.
You have really done well. I have a question.
If we have 100+ repositories, are we suppose to list all of them in the ConfigureServices Method? That I feel might be difficult to manage. Your advice please. Thank you
I have this question too. Do you have answer yet?
Thanks for posting the video. This is very useful. Can you post link to download source code of the project shown in the video.
Repository Pattern is one of the best pattern
Sir, make a video on onion architecture as well.
Thank you very much for teaching us.
Of course! Onion architecture explained by Mr Venkat will be very easy to understand as he knows how to bring difficult contexts simple and clear. Thanks to him for help developers.
Thanks Sir I learn a lot from you Why not singleton object of sql repository
When to use pros and cons
Do you know the answer?
You rock sir
Do you recommend using the generic repository pattern?
Thanks Venkat.
Long live to you sir
thank you
is that code thread safe ? what about case the 2 requests are trying to change employee details ? anyway love your videos! perfect teacher.
do we put our "repositories" in the models folder?
What if we wanted to use both sqlrepository and inmemory..How to register in startup class and make use of both
Sir can you say how is AppDbContext injected in SQLEmployeeRepository? I am not able to understand this part
Nicely explained but it seems similar to video on DI. Again the same doubt how one can have reference of multiple store repository at the same time, in this case InMemory and SQL repositories and use one on the fly as per requirement?
How to consume stored procedure and views with EF Core ?, it looks complicated compared earlier EF, can you please give some lessons using dapper
I am getting this exception, whats wrong with me?
InvalidOperationException: The DbContext of type 'AppDbContext' cannot be pooled because it does not have a single public constructor accepting a single parameter of type DbContextOptions.
Same. Did you find solution ?
Yes.. I resolved
@@saleemthuvvur7510 please explain the solution #saleem. THAnks
Some people say that Repo pattern over EntityFramework is antipattern. EntityFW is already repository.
Also not sure if .Save() inside of each repo method is good idea. What if you need to do few entity operations during request - then it will be few DB transactions. Probably better to have BaseRepo where you do generic retrival, update, create and save operations.
Sir, will you talk about asynchronous programming in the repository pattern ? Regards
Hi. Does that repository can also be use to other classes or entities like department, product, customer tables? Thank you
I thought ef core suggests that you don’t use repository pattern it slows it down when it already implements.
hi venkat, one question in realtime scenario will use only with one databse(SQl,Oracle,..) we don''t need to create repositories multiple, Then how this repository pattern useful.
Seperation of concerns. Back in the days when we were using ADO, we also created a data access layer that gets data from SQL and pass back to the caller which is the business logic layer. I see this repository pattern is pretty much doing the same thing.
At 4:05 and several other places, why not just reuse the GetEmployee method instead of calling _employeeList.FirstOrDefault?
What editing feature you use to copy withing Visual Studio ?
Please can you up thing one step by making a Generic Repository Pattern. Thank you
can you please make one video of common repository and unit of work patterns as well?
sorry sir,i dont think repository pattern is neccesary.We 've created the dbContext instance by depency injection,why not just use the methods of our appDBContext to access the database in the controller action method?
A lot of the topics that Venkat teaches may seem unnecessary in small projects. But he's preparing you for when you go into larger and complex projects.
Having a repository class ensures you retrieve data the same way everytime, as you may require the same data from more than one business logic layer components.
what happens if I use AddSingleton instead of AddScoped to persist the same repository instance across all http requests
Do you know the answer?
Sir, why is private context not defined as _context in: private readonly AppDbContext context;
Still its hard coded in startup. what if we want on conditional basis.
Why would we need a repository? Can't we directly implement those CRUD methods in a service? Like EmployeeService which has a readonly private AppDbContext to work with?
Why add another layer (repository)?
Or am I just mistaking naming conventions and in this video Repository is a sort of Service?
I'm getting a red squiggley line in the following code Department = Dept.HR in the MockEmployeeRepository. Should I have some Properties in the Department Class? Thanks !
Hello Ronald - Here is the Dept enum. Hope this helps.
namespace EmployeeManagement.Models
{
public enum Dept
{
None,
HR,
IT,
Payroll
}
}
Sir plz make vedios on react js. Which will be implement in mvc core.
what's there in repository pattern. I am feeling like the interface-implementation concept only
from where we are injecting the AppDbContext to the SQLEmployeeRepository constructor as a parameter !?
we have to write seperate repo for every table in database
Thank you so much for this amazing tutorial,
For people using API, to display the result, use the following code in controller:
[HttpGet]
public IActionResult Get()
{
var employees = _employeeRep.GetAllEmployee();
return Ok(employees );
}
This question might be out of topic, but how can you register DI outside of compile time to make it more configurable without recompiling?
I don't understand your question. Do you mean in a separate project/ class library?
@@steveymcneckbeard I mean register dependencies using an external file or config file so nobody has to recompile codes.
I am not getting error cannot open databse . I am getting the error Object reference not set to an instance of an object. @foreach (var employee in Model). Please help me on the same.
Why not AddSingleton for the SQLEmployeeRepository service?
Not sure if this has already been answered or not, but if you do AddSinglton an exception will be thrown:
Singleton ImplementationType: EmployeeManagement.Models.SQLEmployeeRepository': Cannot consume scoped service 'EmployeeManagement.Models.AppDbContext' from singleton 'EmployeeManagement.Models.IEmployeeRepository
Why you don't use Async in Repository?
So not this one ( video and tutorial) is great, all your videos are, but when one tutorial with Data Access and stored procedures , for those who has already databases ,stored procedures, triggers..etc? Thanks
Hello Sir
HTTP Error 500.30 - ANCM In-Process Start Failure
I got this error while running the project, how to fix this ?
As I have done the same things that you have done in the project so far.
Please Reply as soon as possible
Sir how attach SEO framework in asp.net core
If you have problems running the pogram it might be because you don't have the default page as index just put app.UseMvcWithDefaultRoute(); before app.UseMvc(routes =>
{
routes.MapRoute("default", "{controller=Home}/{action=Details}/{id=2}");
}); and it should work (version 3.1)
Plz let me know control period key
1) Why AddScoped and not AddSingleton?
You will hit an error if you use AddSingleton. This is because internally services.AddDbContext adds the context as a scoped service and you can't use a scoped service inside a singleton service.
Singleton service - Instance created on first request, stays alive and shared by all users until the application shuts down.
Scoped service - Instance created on first request of a web request, stays alive and used only by the same web request.
So why is the dbcontext added as scoped instead of singleton? Because
* We would not want to have a dbcontext service to be shared by multiple users.
* If it is a singleton service, it will stay alive and keep using more and more system resources for the hundreds and thousands or even millions of database calls and will soon crash the application.
Please send home controller file coding