Please create a database named "BookStoresDB" and then run this script - www.github.com/CuriousDrive/BookStores/tree/master/Database%2FGenerateData.sql
Starting my own business, have a couple years of coding experience but not in all the right places yet. This and your blazor videos will help out, thanks. Hope your channel keeps growing as blazor gets more popular.
Starting a new business is lot work. I am glad that the videos are helping you. I try my best to explain the concepts. Don't hesitate to contact if you get stuck anywhere. Thanks for watching 😊
Great tutorial, thank you! Right what I was looking for. When researching this topic (Web API) there is often a lot about interface and repository. The approach you showed is more easy to grasp for a beginner.
Thanks for watching Simon. I made another video in which I made this process even easier and covered more topics. Hopefully this one will be helpful. ua-cam.com/video/DoYmpAPoixI/v-deo.html
There were two abruptions I faced when following your video series and can be improved: 1. The user login method wasn't created when using visual studio > add controller > scaffold new item. I presume you made it backstage and later in your uploaded videos, it suddenly appeared to viewers. Even, the scaffolding part was missing. 2. The link to your GitHub project > 'code.txt' file doesn't contain the code you showed in the videos. For the students, the video series is worth giving time. I learned a lot in such a short video series about Web API and associated tooling to professionally handle this project. The knowledge given in this series highly overrides the above abruptions being pointed.
Thanks Waqas, that's an awesome feedback. I see what you are saying about the login method. I did add that behind the scenes and did not scaffold it. But visual studio wouldn't have scaffolded as it not one of the EF Core method. I hope that makes sense. And I used "code.txt" file for back up, it is not part of the tutorial. Thanks again for suggesting this tutorial to students.
Probably the best video series to learn reverse engineering in . Net core web api.. Thank you so much sir.. If possible please make videos where we will have to join tables in db first approach using ef core
Thank you so much for kind words Arif. Actually, I have already made a video on loading data from related tables. Loading related data video -> ua-cam.com/video/YucN7Qu_LDs/v-deo.html and you can find the whole series here -> ua-cam.com/play/PL4WEkbdagHIQVbiTwos0E38VghMJA06OT.html
Welcome to the channel. Please subscribe and share with your friends. You can also ask questions on Sunday morning live stream. Please try to be part of it.
Thanks for this. I hope you can cover on future parts how to create an independent method for each CRUD operation instead of using the same method for all operations... And how to call each method from one on the UI technologies you mention at the begining.
Yes. I am going to cover all the important features of Entity Framework Core and ASP.NET Core Web API in this series. And the idea is to call this Web API from my Blazor and Xamarin project that I have already posted on my channel. And hopefully I can also call it from flutter,android and all the other cool languages in next projects....
Can somebody explain to me why he has "bookAuthors" array at 9:50? The model generated by scaffolding command made the field for that? When i use it myself, it was not created. Thank you in advance!
@@CuriousDrive Thank you for making such a greate videos! I want to ask you something: there is any chance to make a video about implementing JWT in Angular? I think there are alot of people who are searching for frontend stuff explained in the way you do.
Hi great tutorial! But how did you get the BookStoreDB at 2:40 is that something you made earlier? If so how would I create it? Or If you know any other tutorials similar that I could look at that would be great.
Hi. How to use db scaffold if a table doesnt have any primary key? I am able to use the command. but get an exception while making the request- InvalidOperationException: The navigation '' cannot be added because it targets the keyless entity type ''. Navigations can only target entity types with keys.
I don't think it is currently possible. Even I did not know about this until I googled about it. Please check below resources. stackoverflow.com/questions/39701068/scaffold-dbcontext-creating-model-for-table-without-a-primary-key github.com/dotnet/efcore/issues/5719 github.com/dotnet/efcore/issues/5913
Honestly it depends on the size of your project. If you are making a project where you have less than 10 tables and you don't really care about your data in the future then CodeFirst is a easy and fast approach. But you have lot of data now or there will be in future then I would go with DatabaseFirst approach. Because then I have freedom to switch to any other ORM framework. And you won't have to maintain your migrations. Your architecture should be independent of your framework. Always build your base first. that's how I code :)
Great content! I have a question, for the Scaffolding Command, what happens if you want to update the EF based on new updates made to the database? What is the command for that?
Hello Nate. same command. Just use "-f" at the end of the command. That regenerates the models and DdContext and overrides the current files with updated models. Please check below article. docs.microsoft.com/en-us/ef/core/managing-schemas/scaffolding?tabs=dotnet-core-cli#updating-the-model
let me ask one more question, as I understood, whenever we make a call to database, we create new instance of context, and as so, we pull of all of the data (including all of BbSetsName ) from databases to our context object. did I get correct? in other word, this approach is assumes heavy data transfer from/to database .
No. EF core does not make call to the database when you create the instance of DBContext. It makes calls when you access the DBSet. And if you use LINQ to filter your collection then it creates the query with where condition. Performance was the main focus when they were designing EF core. I hope that makes sense
I got a question to ask regarding to controller, here you use very simple way to connect to database to pull or add a new data (i.e. author). in other cases, many people use dependency injection where they need to go through series of settings in startup, repositories, and controller (particularly dependency injection in controller). just wondering which approach is preferable? this one (i.e. using(new connection object ... )) is obviously more simple in terms of configuring and using in controller....
Artavazd, that's a great question. The reason why I did not use dependency injection in this case because it would had been difficult for beginners to understand EF Core. But if your DI concepts are clear and you know how your app should be structured to be durable then please use DI.
Iam using Postgresql. When Iam connecting using command Build fail msg is showing in console. Default project and connection is correct. Could u help for this
Hello Athira, If you are getting build error when you run the command then you have build errors in the current solution. Please fix those and then run the command. If you are getting build error after running this scaffolding command then please share the error message. I will try and look up the error. It could be something related to PostgreSQL database.
@@CuriousDrive Thanks I am waiting and plz try to make tutorials for how to consume WEB APIs in Xamarin.Forms with Azure like a complete realtime application.
question on the "using" statement I'm new to c# and was just wondering what this called due to the size or Bookstoredbcontext and wanted to dispose of this reference after being implemented?
I am glad to hear that you are learning C#. "using" statement is used when you want to dispose the object after the code block. This is usually used with the objects which use lot of resources or open connections when they are initialized. We don't want those objects in the memory forever.
Hello Kearl, I think you are looking for loading related data. I made a video about it in the same series. Please check the video below. ua-cam.com/video/YucN7Qu_LDs/v-deo.html
in asp.net core web api : if there are 10 method in one controller i want 10 method return in json formate and 10 method return in xml formate then how will do it?
Hello Mithilesh, sorry for the late reply. Please check below article for producing responses in different formats docs.microsoft.com/en-us/aspnet/core/web-api/advanced/formatting?view=aspnetcore-5.0
I have a large database with 190 tables... I've generated the entity framework model... how do I auto generate the web api from the entity framework model? I don't want to do it buy adding a controller for each table...
Hello Selvakumar, Please follow this article for calling stored procedures in EF core. www.entityframeworktutorial.net/efcore/working-with-stored-procedure-in-ef-core.aspx
Esto sucede porque tienes que tener el "Sql Server Management Studio" Conectado, ejecútalo para que tu instancia este disponible y se pueda realizar el Scaffold, saludos
Hey. I am geting, InvalidOperationException: No database provider has been configured for this DbContext. Issue Description , can you suggest possible solution.
It looks like project is not able find which DB provider you are using. Did you install SQL Server DB provider? If not then you can get it from - www.nuget.org/packages/Microsoft.EntityFrameworkCore.SqlServer/ Also when do you get this error message. When you compile, run or some other time?
how to solve this issue ( A connection was successfully established with the server, but then an error occurred during the login process. (provider: SSL Provider, error: 0 - The certificate chain was issued by an authority that is not trusted.)) , i am using .net core 7
You can run the API and share the IP address of your machine and port number on which the API is running on to whoever wants to use it. Or you can host it on IIS. I have made a video about it. Please check the link below. ua-cam.com/video/b0v4_Kv4_RA/v-deo.html
Thanks for the refresher on scaffolding and EF, and for showing me how to create an API. How did you make your data list show with carriage returns? Mine shows across my browser window without line breaks. Is that a rendering setting somewhere?
If i have a Burger class with salad class relationship and the salad i want is already in the database, how do I connect it to my new burger when I add it to database??
Could you include the mdf file to your db? the.Bak file is incompatible with my server version. Alternatively, you could include the query you used ot create the file. TIA.
@@CuriousDrive I installed the latest sqlexpress and followed you instruction on how to regenerate the schema, but getting error "Severity Code Description Project File Line Suppression State Error SQL80001: 'SORT_IN_TEMPDB' is not a recognized CREATE TABLE option. BookStoresWebAPI C:\Learn\MicroSoft\UsingVisualStudio\Blazor\BookStoresWebAPI\GenerateData.sql 939 " when I tried to execute the query file. Any suggestion?
When I run Scaffolding Command. I get this error: The specified deps.json [D:\git\INT3RCEPT0R\Magazyn\MagazynSkladowania\MagazynSkladowania\MagazynSkladowania.deps.json] does not exist Can You help me?
Can you please paste the whole stack trace here? I am not sure why you are getting the error. Maybe you don't have the correct .NET framework installed.
I use this command and works Scaffold-DbContext -Connection "Server=.;Database=BookStoresDB;Integrated Security=True;Trusted_Connection=True;" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models
Yes. I noticed that. I am actually working on creating another video series for EF Core .NET5 and .NET6(when it gets released). Thanks for your comment. I am sure that will help others.
They seem to be fine for other people. You can download this video and use some online tools to increase audio gain f you'd like. I will loose view counts if I re-upload these videos, also subscribers won't like that.
Hello! Is there a reason why you installed 3.0.0 and not 3.0.1? I know you said you've created 3.0 Web API project, so in this case you cannot install packages that are greater than 3.0.0?
When was working on this demo, 3.0.1 had just come out. And I did not want to run into the issues during the demo. But it should work just fine. Actually, I suggest viewers to install the latest .NET
@@CuriousDrive thanks. I usually don't install the latest latest because it's possible to not work with tutorials in general and to search for the solutions all over the internet :)) (I only do school projects)
I am afraid I don't have that anymore. Are you facing any issues running below query? github.com/CuriousDrive/BookStores/blob/master/Database/GenerateData.sql
You are welcome Artavazd, you can use below query to generate the data. Please follow the instructions on the GitHub repo. github.com/CuriousDrive/BookStores/blob/master/Database/GenerateData.sql
@@CuriousDrive thank you very much for your help. it worked, but something was really strange happen... when I downloaded the file, and then I imported that file to server management studio, it did not work, so I had to open the file in web browser, copy the contents from the browser into the new query file, and then execute it, otherwise, the generatedata.sql file didn't work... when I checked the contents of the generatedata.sql file in notepad, it turned out that it has a mainly html tags (similat of the github page),....
I would create a Blazor app with Auth support in it and then replace the connection string in the app with the connection string of your database and then spin it off for generating the identity columns.
Sure. Please check file at BookStores/BookStoresWebAPI/Database/Backups/BookStoresDB.sql. If you run this file in your SQL express you will be able to take a look at the data. You will have you use Pomelo.EntityFrameworkCore.MySql package to scaffold
Hi Amazing work Quick question you didnt mention if we need few tables not all the database tables as i have 100 tables and not requires all the tables. Also how we play with sql stored procedure any video for it
Hey Imran, I did miss out on mentioning that. I think I mentioned in comment section of my next video on how to do that. I am going to make videos on how to call stored procedure in my future videos I just thought of covering authentication and authorization part first.
Mithilesh, I have plans to make another video series on ASP.NET Web API for .NET 5 & 6. I am going to add this topic in the new series. Thanks for the suggestion.
Hi Man, I am new to IT. I am getting errors when I restore your Database backup to my SQL SQL server. Please can you share the latest backup or script? Thanks in advance
Hi Rajasekhara, I know other people were getting some errors too. I changed the way you can restore the database. Please create a database named "BookStoresDB" then run the script at "BookStores/Database/GenerateData.sql". I have written the instructions at - github.com/CuriousDrive/BookStores
May i know how do you know that after localhost/author? how do you know it is "author"? Have you define it somewhere else? Sorry for asking, i am still new to web api
You will have to define the route on top of your controller. Like this [Authorize] [Route("api/[controller]")] [ApiController] public class AuthorsController : ControllerBase {} Where [controller] attribute is the name of the controller "AuthorsController". Then the path will be localhost:port/authors
Yes. "Authors" is substring of "AuthorsController" hence the path "localhost/authors". They have designed it in this way so that developer maintain the consistency through the project. Check out this below link. They have mentioned how routing works in ASP.NET web api docs.microsoft.com/en-us/aspnet/core/tutorials/first-web-api?view=aspnetcore-3.1&tabs=visual-studio#routing-and-url-paths
Hi! when restore the backup file there was an error occurred as "ADDITIONAL INFORMATION: System.Data.SqlClient.SqlError: The database was backed up on a server running version 14.00.3006. That version is incompatible with this server, which is running version 11.00.2100. Either restore the database on a server that supports the backup, or use a backup that is compatible with this server. (Microsoft.SqlServer.SmoExtended)" . how can I restore this backup file.
Hello Kokila, It looks like the backup is not compatible with your SQL Server. I suggest that you should create the DB named as "BookStores_DEV" and then you can run below query to generate the schema and data in that in DB. github.com/CuriousDrive/BookStores/blob/master/Database/GenerateData.sql Thanks for watching.
Yes. You can use dotnet CLI commands to install nuget packages on linux or mac machines. Please check the below command for EF Core package. dotnet add package Microsoft.EntityFrameworkCore --version 5.0.2
how do I use the database that you provide, I've downloaded it and then after that I enter it into mssqlserver. after I clicked the "execute" button then an error occurred.
@@CuriousDrive There are quite a lot of error messages, such as Incorrect syntax near 'CONTAINMENT' then there is Valid values of the database compatibility level are 80, 90, or 100. And also User does not have permission to alter database 'BookStores_DEV', the database does not exist, or the database is not in a state that allows access checks. At the end of the message, it says ALTER DATABASE statement failed. did I do something wrong? (I'm using mssql server management 2008 by the way)
Hi there, Nice to meet you, i would like to thank you about your videos ! i have one question regarding JWT Token i have an issue with UserWithToken Model, because when i implemented your code i still have an issue to return UserWithToken Object could you please show me the Model or let me know how can i resolve my issue. Many thanks in advance.
Awesome tutorial. May i know command for How to remove BooksDBContext and add another Database? Through command prompt package manager console. scaffolding
Thanks for commenting Sujashree. Is this what you are looking for? Scaffold-DbContext 'Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=Chinook' Microsoft.EntityFrameworkCore.SqlServer
Jeremaine, YES. the only thing that you will need to change is the provider in that case. You can follow this article - dev.mysql.com/doc/connector-net/en/connector-net-entityframework-core-scaffold-example.html
@@CuriousDrive Thank you..! Im looking forward to it. But in that there wont be any view or presentation layer. it wud be API. In Api -Controller ,Business Layer -Model .then Data Access Layer where database connections and queries are written. Applying dependency injection. Without Entity Framework .only asp .net core + Web Api. using stored procedures in sql server .performing CRUD operation with a siple example so that beginners like me could easily understnd. thank you Again.
Hey Luigi, I personally read either from microsoft docs - docs.microsoft.com/en-us/ef/core/ or this website has very organized information about EF in general - www.entityframeworktutorial.net/what-is-entityframework.aspx I see what you are saying though, I miss reading books too. These frameworks are updated every quarter, I don't think any book will be good as it will be outdated pretty soon. microsoft docs does give you an option to download PDF on left bottom corner though. Something to read on the train ride :)
I know. Other people complained about that too. I did not have a good microphone and no video editing skills. The new videos are better. Thanks for watching this one :)
Hello Raghavendra, I have plans to make a video series on ASP.NET Web API for .NET 5 framework. I am going to cover how you can call stored procedure in that series but meanwhile you can take a look at this article. I hope this helps. www.entityframeworktutorial.net/efcore/working-with-stored-procedure-in-ef-core.aspx
Code - github.com/CuriousDrive/BookStores
Thanks for watching, please share with your friends :)
I want to follow along the way in this tutorial series. I didn't find your BookStore.bak file as shown in the video. Please guide.
Please create a database named "BookStoresDB" and then run this script - www.github.com/CuriousDrive/BookStores/tree/master/Database%2FGenerateData.sql
@@CuriousDrive thanks. It worked like a charm.
Prefer to put file .bat and we just import it.
Starting my own business, have a couple years of coding experience but not in all the right places yet. This and your blazor videos will help out, thanks. Hope your channel keeps growing as blazor gets more popular.
Starting a new business is lot work. I am glad that the videos are helping you. I try my best to explain the concepts.
Don't hesitate to contact if you get stuck anywhere. Thanks for watching 😊
@@CuriousDrive you are so nice person thanks for to kind behaviour Allah always bless you.
Great tutorial, thank you! Right what I was looking for. When researching this topic (Web API) there is often a lot about interface and repository. The approach you showed is more easy to grasp for a beginner.
Yes the idea was to get people started with entity framework instead scaring them. Thanks for a lovely comment 😊
This is a good tutorial. I am yet to watch remaining videos in the list, but I must say that the beginning is good :) Thank you..
Thanks Yogesh. Let me know if you run into any issues.
Brilliant video. Very clear and I learnt a lot. Thank you.
Thanks for watching Simon. I made another video in which I made this process even easier and covered more topics. Hopefully this one will be helpful.
ua-cam.com/video/DoYmpAPoixI/v-deo.html
Awesome tutorial.. crisp and clear information. thank you.
Thanks for watching Kumaresan, Please share with your friends :)
Thank you so much, this video is amazing from all videos which are uploaded on youtube really thank you so much...
Thanks for watching Riti. Please share with your friends :)
Video is very important to me. Thank you bro!
I am glad this was helpful to you. Please share with your friends :)
Thanks for the clear tutorial. I normally use SQL Server with stored procs and data access layers. This EF is all new to me so it's very useful.
Yes, it's very easy to use. Makes our lives easier. Thanks for watching the video.
A comprehensive video series. Loved your videos.
There were two abruptions I faced when following your video series and can be improved:
1.
The user login method wasn't created when using visual studio > add controller > scaffold new item.
I presume you made it backstage and later in your uploaded videos, it suddenly appeared to viewers.
Even, the scaffolding part was missing.
2.
The link to your GitHub project > 'code.txt' file doesn't contain the code you showed in the videos.
For the students, the video series is worth giving time. I learned a lot in such a short video series about Web API and associated tooling to professionally handle this project. The knowledge given in this series highly overrides the above abruptions being pointed.
Thanks Waqas, that's an awesome feedback. I see what you are saying about the login method. I did add that behind the scenes and did not scaffold it. But visual studio wouldn't have scaffolded as it not one of the EF Core method. I hope that makes sense.
And I used "code.txt" file for back up, it is not part of the tutorial.
Thanks again for suggesting this tutorial to students.
Awesome video series.
Best and quick learning.
thanks
Thanks for watching Wikki. and thanks for a lovely comment.
Simple and concise - thank-you.
Thanks for a lovely comment P W. I am glad you found the video helpful
Best series I found on the topic
Thanks for a lovely comment lerato :)
Probably the best video series to learn reverse engineering in . Net core web api.. Thank you so much sir.. If possible please make videos where we will have to join tables in db first approach using ef core
Thank you so much for kind words Arif.
Actually, I have already made a video on loading data from related tables.
Loading related data video -> ua-cam.com/video/YucN7Qu_LDs/v-deo.html
and you can find the whole series here -> ua-cam.com/play/PL4WEkbdagHIQVbiTwos0E38VghMJA06OT.html
@@CuriousDrive actually i am new to your channel... I will surely go through all of ur videos.. Keep making such videos sir
Welcome to the channel. Please subscribe and share with your friends.
You can also ask questions on Sunday morning live stream. Please try to be part of it.
New Subscriber here. Thank you for sharing this video. Great explanation! Please keep up the great work. Followed through with no problem.
Thanks for an awesome. Let me know if you run into any issues.
Thanks for this. I hope you can cover on future parts how to create an independent method for each CRUD operation instead of using the same method for all operations... And how to call each method from one on the UI technologies you mention at the begining.
Yes. I am going to cover all the important features of Entity Framework Core and ASP.NET Core Web API in this series. And the idea is to call this Web API from my Blazor and Xamarin project that I have already posted on my channel. And hopefully I can also call it from flutter,android and all the other cool languages in next projects....
Curious Drive That’s amazing, will keep in touch, subscribed!
Can somebody explain to me why he has "bookAuthors" array at 9:50? The model generated by scaffolding command made the field for that? When i use it myself, it was not created. Thank you in advance!
Nvm, i got it!
I am glad that you figured it out
@@CuriousDrive Thank you for making such a greate videos! I want to ask you something: there is any chance to make a video about implementing JWT in Angular? I think there are alot of people who are searching for frontend stuff explained in the way you do.
This is awesome, loved your vdo, easy to understand, to the point, thank you so much.
Thanks for watching himanshu
Hi great tutorial!
But how did you get the BookStoreDB at 2:40 is that something you made earlier? If so how would I create it? Or If you know any other tutorials similar that I could look at that would be great.
Hello Green Deer, I have added the DB script to generate the BookStoresDB. Please check below GitHub repo for that.
github.com/CuriousDrive/BookStores
so good video , THANK SO MUCH.
Thanks for watching yiğitcan keskin!!!
Thanks a lot , great tutorial and reminder (:
Thanks for watching Ahmet.
Hi. How to use db scaffold if a table doesnt have any primary key? I am able to use the command. but get an exception while making the request- InvalidOperationException: The navigation '' cannot be added because it targets the keyless entity type ''. Navigations can only target entity types with keys.
I don't think it is currently possible. Even I did not know about this until I googled about it. Please check below resources.
stackoverflow.com/questions/39701068/scaffold-dbcontext-creating-model-for-table-without-a-primary-key
github.com/dotnet/efcore/issues/5719
github.com/dotnet/efcore/issues/5913
@@CuriousDrive Thank you for quick reply :)
Thanks for asking very good question Gokul. Please subscribe to the channel and share with others :)
Hi, this is the first video that I see and I really liked it, you have a new subscriber. If you fix a new project, use DataBaseFirst or CodeFirst?
Honestly it depends on the size of your project.
If you are making a project where you have less than 10 tables and you don't really care about your data in the future then CodeFirst is a easy and fast approach.
But you have lot of data now or there will be in future then I would go with DatabaseFirst approach. Because then I have freedom to switch to any other ORM framework. And you won't have to maintain your migrations.
Your architecture should be independent of your framework. Always build your base first. that's how I code :)
Great content! I have a question, for the Scaffolding Command, what happens if you want to update the EF based on new updates made to the database? What is the command for that?
Hello Nate. same command. Just use "-f" at the end of the command. That regenerates the models and DdContext and overrides the current files with updated models. Please check below article.
docs.microsoft.com/en-us/ef/core/managing-schemas/scaffolding?tabs=dotnet-core-cli#updating-the-model
Really nice video,
Please make videos on step by step project implemention too
Hi Akhtar, I am not sure if I am following your feedback. Can you please elaborate?
let me ask one more question, as I understood, whenever we make a call to database, we create new instance of context, and as so, we pull of all of the data (including all of BbSetsName ) from databases to our context object. did I get correct? in other word, this approach is assumes heavy data transfer from/to database .
No. EF core does not make call to the database when you create the instance of DBContext. It makes calls when you access the DBSet. And if you use LINQ to filter your collection then it creates the query with where condition. Performance was the main focus when they were designing EF core. I hope that makes sense
@@CuriousDrive Thanks for the explanation.
I got a question to ask regarding to controller, here you use very simple way to connect to database to pull or add a new data (i.e. author). in other cases, many people use dependency injection where they need to go through series of settings in startup, repositories, and controller (particularly dependency injection in controller). just wondering which approach is preferable? this one (i.e. using(new connection object ... )) is obviously more simple in terms of configuring and using in controller....
Artavazd, that's a great question. The reason why I did not use dependency injection in this case because it would had been difficult for beginners to understand EF Core. But if your DI concepts are clear and you know how your app should be structured to be durable then please use DI.
@@CuriousDrive thanks for replay. I got your point. better to learn and understand the both approach.
Thank you. Very good tutorial
Thanks for watching Viktor. Please share with frandzzz :)
Iam using Postgresql. When Iam connecting using command Build fail msg is showing in console. Default project and connection is correct. Could u help for this
Hello Athira, If you are getting build error when you run the command then you have build errors in the current solution. Please fix those and then run the command. If you are getting build error after running this scaffolding command then please share the error message. I will try and look up the error. It could be something related to PostgreSQL database.
Very Useful Content, Thanks a lot...
Thanks but I have question?
How we can create multiple Get Methods in a same Controller with different method names.?
Yes totally. As we progress in the series, I am creating multiple GET methods in a controller.
@@CuriousDrive Thanks I am waiting and plz try to make tutorials for how to consume WEB APIs in Xamarin.Forms with Azure like a complete realtime application.
Outstanding, thank you!
question on the "using" statement I'm new to c# and was just wondering what this called due to the size or Bookstoredbcontext and wanted to dispose of this reference after being implemented?
I am glad to hear that you are learning C#. "using" statement is used when you want to dispose the object after the code block. This is usually used with the objects which use lot of resources or open connections when they are initialized. We don't want those objects in the memory forever.
@@CuriousDrive I'm sure it way is fine but I see most places use the read-only with constructor approach rather than using
How to run sql against context or create a json structure like "books by publisher"?
Hello Kearl, I think you are looking for loading related data. I made a video about it in the same series. Please check the video below.
ua-cam.com/video/YucN7Qu_LDs/v-deo.html
You're saving my live!!!!! thanks man
Thanks for watching Tang. Let me know if you run into any issues :)
in asp.net core web api :
if there are 10 method in one controller
i want 10 method return in json formate
and 10 method return in xml formate then how will do it?
Hello Mithilesh, sorry for the late reply. Please check below article for producing responses in different formats
docs.microsoft.com/en-us/aspnet/core/web-api/advanced/formatting?view=aspnetcore-5.0
I have a large database with 190 tables... I've generated the entity framework model... how do I auto generate the web api from the entity framework model? I don't want to do it buy adding a controller for each table...
Hi friend,
How can i get data through stored procedures?
Hello Selvakumar, Please follow this article for calling stored procedures in EF core.
www.entityframeworktutorial.net/efcore/working-with-stored-procedure-in-ef-core.aspx
Thanks 😊
wat if i added new table in sql server?
i should create model manually
I have a feeling that you have already watched rest of the series already. That must have answered your question
This was useful, however I have a problem! Evertime I run the Scaffold-DbContext command it says "Build Failed" can anyone help me with that ?
Hello Chandini, that means you have syntax error somewhere in the code and you will have to fix it before scaffolding your database.
Esto sucede porque tienes que tener el "Sql Server Management Studio" Conectado, ejecútalo para que tu instancia este disponible y se pueda realizar el Scaffold, saludos
Hey. I am geting,
InvalidOperationException: No database provider has been configured for this DbContext.
Issue Description
, can you suggest possible solution.
It looks like project is not able find which DB provider you are using. Did you install SQL Server DB provider? If not then you can get it from - www.nuget.org/packages/Microsoft.EntityFrameworkCore.SqlServer/
Also when do you get this error message. When you compile, run or some other time?
how to solve this issue ( A connection was successfully established with the server, but then an error occurred during the login process. (provider: SSL Provider, error: 0 - The certificate chain was issued by an authority that is not trusted.)) , i am using .net core 7
Great tutorial, thanks very much bro..
The luckiest number ever :)
Nice video , thanks a lot
It's fun making these demos. Thanks for watching :)
how i can share my API and request from another PC with local network ?
You can run the API and share the IP address of your machine and port number on which the API is running on to whoever wants to use it. Or you can host it on IIS. I have made a video about it. Please check the link below.
ua-cam.com/video/b0v4_Kv4_RA/v-deo.html
Thanks for the refresher on scaffolding and EF, and for showing me how to create an API. How did you make your data list show with carriage returns? Mine shows across my browser window without line breaks. Is that a rendering setting somewhere?
It's json formatter chrome extension. 😊
@@CuriousDrive Thanks that worked!
so simple and great tutorial thank you so much
If i have a Burger class with salad class relationship and the salad i want is already in the database, how do I connect it to my new burger when I add it to database??
Hello Whoomz, great question. Please check my video on "Loading Related Data". Link below.
ua-cam.com/video/YucN7Qu_LDs/v-deo.html
Could you include the mdf file to your db? the.Bak file is incompatible with my server version. Alternatively, you could include the query you used ot create the file. TIA.
@Chris - I added the script in GitHub repo, which will generate schema and data for you. :)
@@CuriousDrive I installed the latest sqlexpress and followed you instruction on how to regenerate the schema, but getting error "Severity Code Description Project File Line Suppression State
Error SQL80001: 'SORT_IN_TEMPDB' is not a recognized CREATE TABLE option. BookStoresWebAPI C:\Learn\MicroSoft\UsingVisualStudio\Blazor\BookStoresWebAPI\GenerateData.sql 939
" when I tried to execute the query file. Any suggestion?
I deleted the 'offending' line --> reran the query --> GOOD!!!
Amazing
Thank you very much.
When I run Scaffolding Command. I get this error:
The specified deps.json [D:\git\INT3RCEPT0R\Magazyn\MagazynSkladowania\MagazynSkladowania\MagazynSkladowania.deps.json] does not exist
Can You help me?
What version of dotnet are you using?
@@CuriousDrive Microsoft .NET Framework Version 4.8.04084
That's why you are getting that error. This command is for .net core 3.1 or greater. I would suggest installing .net 5 as that's latest
@@CuriousDrive How and Where can I change it?
@@CuriousDrive When I create new project in .NET Core 3.1 (LTS). I get same error
Getting this Error on running Saffolding command - Exception has been thrown by the target of an invocation.
Can you please paste the whole stack trace here? I am not sure why you are getting the error. Maybe you don't have the correct .NET framework installed.
I use this command and works Scaffold-DbContext -Connection "Server=.;Database=BookStoresDB;Integrated Security=True;Trusted_Connection=True;" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models
Amazing video!
Thanks for watching 😊
am i the one not able to find the .bak file in the said git link?
The DbSets are plural in the latest release :)
Yes. I noticed that. I am actually working on creating another video series for EF Core .NET5 and .NET6(when it gets released).
Thanks for your comment. I am sure that will help others.
you have saved my semester, thanks a lot
You made my day!!!
Great video
Is it possible for you to increase the sound and upload the files? This sound is very feeble. Video looks great.
They seem to be fine for other people. You can download this video and use some online tools to increase audio gain f you'd like. I will loose view counts if I re-upload these videos, also subscribers won't like that.
Works fine for me!
Hello! Is there a reason why you installed 3.0.0 and not 3.0.1? I know you said you've created 3.0 Web API project, so in this case you cannot install packages that are greater than 3.0.0?
When was working on this demo, 3.0.1 had just come out. And I did not want to run into the issues during the demo. But it should work just fine. Actually, I suggest viewers to install the latest .NET
@@CuriousDrive thanks. I usually don't install the latest latest because it's possible to not work with tutorials in general and to search for the solutions all over the internet :)) (I only do school projects)
Ohh okay. Let me know if you run into any issues. Here to help!!!
Can you share first database? i found the database on your github but i want the original database at the start of the course
I am afraid I don't have that anymore. Are you facing any issues running below query?
github.com/CuriousDrive/BookStores/blob/master/Database/GenerateData.sql
What about getting the record based on the id entered into the get?
Hey Charelse, I covered that part in below demo.
ua-cam.com/video/uPJ2-6YPRjM/v-deo.html
Let me know if you have questions related to that video.
@@CuriousDrive Thank you.
thanks for the video, trying to import the databas.bak file, but failed, any tips or advise?
You are welcome Artavazd, you can use below query to generate the data. Please follow the instructions on the GitHub repo.
github.com/CuriousDrive/BookStores/blob/master/Database/GenerateData.sql
@@CuriousDrive thank you very much for your help. it worked, but something was really strange happen... when I downloaded the file, and then I imported that file to server management studio, it did not work, so I had to open the file in web browser, copy the contents from the browser into the new query file, and then execute it, otherwise, the generatedata.sql file didn't work... when I checked the contents of the generatedata.sql file in notepad, it turned out that it has a mainly html tags (similat of the github page),....
Luv you maaaan
Love you too bruh!! Thanks for watching. Please share with your friends :)
How can I add Identity for existing database ?
I would create a Blazor app with Auth support in it and then replace the connection string in the app with the connection string of your database and then spin it off for generating the identity columns.
Hey can i ask what your database look like before scaffolding it?
btw I'm using mysql is it necessary for that?
Sure. Please check file at BookStores/BookStoresWebAPI/Database/Backups/BookStoresDB.sql. If you run this file in your SQL express you will be able to take a look at the data.
You will have you use Pomelo.EntityFrameworkCore.MySql package to scaffold
@@CuriousDrive ok thanks
Hi
Amazing work
Quick question you didnt mention if we need few tables not all the database tables as i have 100 tables and not requires all the tables. Also how we play with sql stored procedure any video for it
Hey Imran, I did miss out on mentioning that. I think I mentioned in comment section of my next video on how to do that.
I am going to make videos on how to call stored procedure in my future videos I just thought of covering authentication and authorization part first.
How to Access/Use/ Call Stored Procedure in Entity Framework Core 3.1 DATABASE First Approach C#
Mithilesh, I have plans to make another video series on ASP.NET Web API for .NET 5 & 6. I am going to add this topic in the new series. Thanks for the suggestion.
Hi Man,
I am new to IT.
I am getting errors when I restore your Database backup to my SQL SQL server.
Please can you share the latest backup or script?
Thanks in advance
Hi Rajasekhara, I know other people were getting some errors too. I changed the way you can restore the database. Please create a database named "BookStoresDB" then run the script at "BookStores/Database/GenerateData.sql". I have written the instructions at - github.com/CuriousDrive/BookStores
I am getting below Error
An assembly specified in the application dependencies manifest (ApplicationName.deps.json) was not found:
When are you getting this exception? Have you cloned the GitHub repo?
May i know how do you know that after localhost/author? how do you know it is "author"? Have you define it somewhere else? Sorry for asking, i am still new to web api
You will have to define the route on top of your controller. Like this
[Authorize]
[Route("api/[controller]")]
[ApiController]
public class AuthorsController : ControllerBase
{}
Where [controller] attribute is the name of the controller "AuthorsController". Then the path will be localhost:port/authors
@@CuriousDrive does the "authors" is substring from any strings? Or automatically it will be like that? Is there any docs I can refer to? Thanks.
Yes. "Authors" is substring of "AuthorsController" hence the path "localhost/authors".
They have designed it in this way so that developer maintain the consistency through the project.
Check out this below link. They have mentioned how routing works in ASP.NET web api
docs.microsoft.com/en-us/aspnet/core/tutorials/first-web-api?view=aspnetcore-3.1&tabs=visual-studio#routing-and-url-paths
Thnx for this easy tut...
Thanks for watching Ioan. Please subscribe and share with your friends
Hi! when restore the backup file there was an error occurred as "ADDITIONAL INFORMATION:
System.Data.SqlClient.SqlError: The database was backed up on a server running version 14.00.3006. That version is incompatible with this server, which is running version 11.00.2100. Either restore the database on a server that supports the backup, or use a backup that is compatible with this server. (Microsoft.SqlServer.SmoExtended)" . how can I restore this backup file.
Hello Kokila, It looks like the backup is not compatible with your SQL Server. I suggest that you should create the DB named as "BookStores_DEV" and then you can run below query to generate the schema and data in that in DB.
github.com/CuriousDrive/BookStores/blob/master/Database/GenerateData.sql
Thanks for watching.
@@CuriousDrive thank u so much!
can i do this on linux? how can I add nuget packages in terminal?
Yes. You can use dotnet CLI commands to install nuget packages on linux or mac machines. Please check the below command for EF Core package.
dotnet add package Microsoft.EntityFrameworkCore --version 5.0.2
Instead of adding ,update Author in same [HttpGet] which is not recommended, there are many http method can handle CRUD functionalities.
how do I use the database that you provide, I've downloaded it and then after that I enter it into mssqlserver. after I clicked the "execute" button then an error occurred.
Hello Aji - what error are you getting? Maybe I can update the query to fix it for everyone?
@@CuriousDrive There are quite a lot of error messages, such as Incorrect syntax near 'CONTAINMENT' then there is Valid values of the database compatibility level are 80, 90, or 100. And also User does not have permission to alter database 'BookStores_DEV', the database does not exist, or the database is not in a state that allows access checks. At the end of the message, it says ALTER DATABASE statement failed. did I do something wrong? (I'm using mssql server management 2008 by the way)
Why store the DB Connection String in your Context instead of Storing it in your appsettings.json?
Hello Sunil, I fixed that as part next episode. you can find that episode here - ua-cam.com/video/7a7zYOTTXRs/v-deo.html
Tutorial is very good. Are there any new series on .Net 6/7/8/ Web api??
Hi , Is there any update from your channel?
Hi there, Nice to meet you, i would like to thank you about your videos ! i have one question regarding JWT Token i have an issue with UserWithToken Model, because when i implemented your code i still have an issue to return UserWithToken Object could you please show me the Model or let me know how can i resolve my issue. Many thanks in advance.
good work and thanx
Awesome tutorial. May i know command for How to remove BooksDBContext and add another Database? Through command prompt package manager console. scaffolding
Thanks for commenting Sujashree. Is this what you are looking for?
Scaffold-DbContext 'Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=Chinook' Microsoft.EntityFrameworkCore.SqlServer
Is the web api you've created a rest api?
Yes. You are correct.
nice tutorial
Thanks for watching Anirudh :)
Can I user mysql db for this?
Jeremaine, YES. the only thing that you will need to change is the provider in that case.
You can follow this article -
dev.mysql.com/doc/connector-net/en/connector-net-entityframework-core-scaffold-example.html
hey can u pls tell me how to update generated models from scaffolding?
Hello Akshay, I am explaining that in the next episode of the series.
has anyone encounter this error: System.Runtime.InteropServices.SEHException: 'External component has thrown an exception.'
??
What version of VS are you using and do you have .NET core installed on your machine?
@@CuriousDrive Thanks for your response, It was about 'Platform Target', I changed it from 'Any CPU' to 'x86' and it runs perfectly,.now. ❤
Excelente
Thanks Enrique. Please share with others :)
this explanation really helps me..thank you !
could you please explain web api using 3 layered architecture and MVC together.
I am glad that it was helpful. your suggestion sounds like whole another series that I should work on.
@@CuriousDrive Thank you..! Im looking forward to it.
But in that there wont be any view or presentation layer. it wud be API. In Api -Controller ,Business Layer -Model .then Data Access Layer where database connections and queries are written. Applying dependency injection.
Without Entity Framework .only asp .net core + Web Api. using stored procedures in sql server .performing CRUD operation with a siple example so that beginners like me could easily understnd. thank you Again.
@@CuriousDrivelike Controller and Interface (Repository /Service Pattern) |using ASP.NET Core Web API performing Basic CRUD operation
Hello, could you suggest me the best book on EF Core and Web API Core? Maybe one that you have used to in the past.
Hey Luigi, I personally read either from microsoft docs - docs.microsoft.com/en-us/ef/core/
or this website has very organized information about EF in general - www.entityframeworktutorial.net/what-is-entityframework.aspx
I see what you are saying though, I miss reading books too. These frameworks are updated every quarter, I don't think any book will be good as it will be outdated pretty soon.
microsoft docs does give you an option to download PDF on left bottom corner though. Something to read on the train ride :)
anyone help me how to import giving database into my database??
Thank you for this video.
It's very useful.
How to set database user name and password on connection string?
Server=myServerName\myInstanceName;Database=myDataBase;User Id=myUsername;Password=myPassword;
Can yo do video on .net core identity using db first approach like without migrations
Thanks for the suggestion Ravi. I do have 2 more videos left in this series. that could be one of them. Thanks!!!
@@CuriousDrive I am eagerly waiting thank you
@@CuriousDrive After the identity complete, register one user with postman or anything.
I had to add "TrustServerCertificate=True" in connection string as well
otherwise it wasn't running
All are good, but I think u need to talk loudly and clearly, cuz I did had my volume up to 80 to watch the video >v
I know. Other people complained about that too. I did not have a good microphone and no video editing skills. The new videos are better. Thanks for watching this one :)
Thanks
Thanks for watching Michael.
Could you please explain one example, How to use stored procedures in webAPI with entity framework
Thanks,
Raghavendra
Hello Raghavendra, I have plans to make a video series on ASP.NET Web API for .NET 5 framework. I am going to cover how you can call stored procedure in that series but meanwhile you can take a look at this article. I hope this helps.
www.entityframeworktutorial.net/efcore/working-with-stored-procedure-in-ef-core.aspx
Nice video. Could you please share the code link. thank you!
Hello Sreenivasa, you can find the code here - github.com/CuriousDrive/BookStores
Thanks for watching. Please share with others
@@CuriousDrive thank you
Could you provide me database sql file? thanks a lot!
There you go - github.com/CuriousDrive/BookStores/blob/master/BookStoresWebAPI/Database/Backups/BookStoresDB.sql
could you pls share the source code
Yes. Vassanth, the code is at - github.com/CuriousDrive/BookStores
Let me know if you run into any issues.
You are Way Ahead from Begineer Perspective
Sorry about that. The beginner videos are coming on the channel this year.