dude i searched the internet for so long and finally i got to the right place. Man, if any out there is watching this, dude you are at the right place. Mr. tim corey keep up the good work.
Between TH-cam and my IAmTimCorey courses I’ve seen this process so many times... but Every time I learn a little more about constructors, classes, dapper, sql dev, using statements, mapping, etc... the understanding that this guy gives us is invaluable. This is something like khan academy for C# ... Believe it or not but you are watching one of the best parts of the internet. thank you man 🙏🏻
I switched from .NET to Node a few months back and fell in love with VueJs/Node/TS... But there's no way I'm not taking full advantage of this tutorial to Make myself more valuable to employers. My eyes just lit up when I saw this. Thank you Tim!
This was brilliant! I've looked at so many videos trying to figure out how to do this but yours was concise, accurate and well presented. You made it look simple to use blazor with a database which is not always the case with other TH-cam tutorials. Thanks!
This is the first of your vids I've watched and I got say we'll done! Like Einstein said: If you can't explain it simply, you don't understand it well enough. I've been struggling with this topic for a few days and your tutorial has cleared up everything for me!
I just figured out how many lines of code I have needlessly written in recent months while working with MySql myself... On the other side you just saved me from wasting even more time and space in the future. I need to do some refactoring this week. Thanks.
Hey Tim. I actually learned to code using your WinForms videos. I took that knowledge and learned Node & Vue and I'm launching a product in the coming weeks which is over 2,000+ hours of code deep but I consider C# and .NET to be imperative to my general 'computer science' understanding. This video has been on my 'todo' list for nostalgia's sake although I don't get to play with C# much these days, I needed a day off from my project and thought this tutorial would help me unwind. I managed to modify the code a bit and connect to my production server/database and I added appsettings.json to .gitignore. Now I have a great template for Blazor/MySQL which can be a lot of fun in the future. Blazor actually feels like a mix of React & Vue which is pretty cool because I like both. I've noticed a trend that a lot of .NET developers eventually gravitate to Angular. I'm sure as people get more comfortable with Blazor that will change but I've always wondered why .NET devs tend to gravitate to Angular. I've seen it more than a handful of times. Is it that Angular has more of an 'Enterprise' feel than it's counterparts? Just wondering your take on that.
I am glad my videos have been so helpful. As to why people seem to gravitate towards Angular from .NET, I'm not sure. It may be a market thing. They see Angular jobs and they start pursuing what is more prevalent to them.
Big thank you from me. I needed exactly this for my project and you uploaded this video on the exact same day. I was really frustrated, that I wasn't able to find something good and then you uploaded your video.
I had trouble with the DELETE - permission problem. In MySQL workbench, used Edit / Preferences / SQLEditor - bottom of page uncheck 'Safe Updates (rejects UPDATES....)'. Then worked OK. You did mention in the video there could have been a problem at this point. As always, great video. Best regards. Jan.
Wow, great tutorial. I have been working/learning EF core for the past couple months. After a series of complex error messages and struggling to do even basic things, I've decided to move to Dapper finally. I should have listened to you earlier lol
0:29 "My goal isn't to entertain you. My goal is to turn you into a world-class developer" - Well, imo you manage to do both at the same time. You educate us in an entertaining way and explain very clear. Really good job. Could you also make a video how to access multiple SQL 'types' such as TSql, MySql, Sqlite in the same project without using an external framework (e.g. because you aren't allowed to), but with the default classes instead? You know, SqlConnection, MySqlConnection, DbConnction, SqlCommand, MySqlCommand, DbCommand, etc... Or if that's too much, a simple video about the Managed Extensibility Framework would help as well. I'm really stuck with that.
Not sure if Dapper qualifies as an "external framework" but the C# Application from Start to Finish course does something like this - it sets up both SQL data access and Text file data access and allows you to choose between the two via a toggle. I'll add your vote for MEF to the list.
Awesome video Tim, as always. Would love to see you take this topic a little further by using some forms for data input and data grids for displaying the data back please. Keep up the great work!
50:00 when ever I create an update statement I always type "Update set where" and then go back and edit what ever I need for that to work. That way I never miss the 'where' and overwrite the whole table since if I was to try and run it with "update person set firstname='bob' where" the query will fail since there is not value set after where. I little tip I got from a colleague at my first developer job. Kind stuck with me and since I've taught others to do the same. I normally don't use delete that much in my day to day work but you could use that tip for delete queries aswell "delete from where" and continue from there.
I’ll go you one better. I *always* write UPDATE statements as SELECT using my WHERE clause first. That way I get a visual check on the records affected by the UPDATE.
@@bunkie2100 I never really got the hang of it that way. I guess I just need to try it for a longer period. I see the benefits of it. I see some of my colleagues do it that way too. I have usually already made a select statement beforehand so I know the result.
Thanks for your video. Dapper seems much more easy to learn and implement than EF. Please can you also do a video showing how to display data in datagrid and how to generate Reports.
Thank you IAmTimCorey! I was wondering. Can we execute a store procedure rather than write down our query? For example: Datable g = access.getPeople();
Hello Sir, thank you for this video! I am currently in the process of learning how to develop Blazor server applications and I have been able to make some progress by implementing basic CRUD operations. However, I am concerned about the security implications of passing IDs to another page without using local storage. Is there a recommended method for achieving this? , do you have any instructional videos on this topic that you can recommend?
Local storage isn't going to increase your security here. That is fully available to the client to manipulate. You need to do security checks on each page and for each action anyway, so passing IDs isn't a security risk.
This is awesome. Thanks. :) I love the tooling MS giving us. It has everything included and core apps can be run on Linux machines, but the MS SQL Server is the only limiting factor. You can't really use it outside of Azure and it's too expensive for personal projects. The free tier isn't enough for real-world personal projects that would be alive over 12 months. MS SQL is really good and would love to use it. Especially loved how you used database projects with TimCoRetailManager. I've searched, but couldn't find any way to use that for MySQL/Postgres. The only add-on I did find was dbForge Fusion for MySQL, but it costs like a $300. Can't really afford that for personal projects.
Well, for personal use, you can use SQL Server Developer Edition, which is free. There is also a version of Microsoft SQL that runs on Linux. Check out this video of running SQL on Docker (on Linux): th-cam.com/video/Yj69cWEG_Yo/w-d-xo.html
Thanks Tim for this video. I was building a project with EfCore with clean architecture, but wanted to refacter EfCore use with interfaces... looks like I can now use Dapper for reads and EfCore for writes if I get this right.
Ah, right. Noted. But that now begets how to replace a dbcontex class and a migration rub in the program class that creates the db and applies a migration upon startup of the application. I guess that might be my suggestion for another video down the road. Of. Ourse, I think I can solve this with the previous Blazir video that was a couple of months ago that showed us a IDatabase interface.
Correct. I did not see the async to be that valuable when the data was already on the machine. This call is valuable when you have an IQueriable where the ToList actually performs the call and downloads the data.
@@IAmTimCorey hi. Thx for answering. I tried it. I wrote the services.builder.........dataaccess line in the right place, and then the blazor app don't run anymore. I can't find another reason, because, when I comment the line out, the app works.
When we publish a project with a data library what folders do we need to include on the server in order to execute the application? The publish process produces one release folder for the Data library and one for the blazor project, how does the blazor project access the data library? If you have any tutorials on migrating this to a linux vm please let me know, great video thank you for your thorough explanations.
Excellent as always Tim. I watched the Blazor Server with SQL access tutorial as well the other day. I noticed that on that one you created an entity(or model?) for the data access library together with the sqldataaccess class. Considering that both are Blazor Server project. Which one do you think is better in terms of design? Also, when I run my app that connects to MSSQL DB it takes a long time to connect and show the list of users, I changed the access from transient to singleton hoping it would help but it didn't do much. Is this to be expected because MSSQL is not started and is being started by visual studio whenever it tries to run? If so then I think this shouldn't be a problem on a web app uploaded on cloud servers since SQL Server should always be up, am I correct in this assumption? Sorry for the long questions.
I am not sure what you are asking in the first question. As for the second question, it all depends on what you mean by a long time. The first time you talk to SQL, it will be a bit slower but it should not be slow. It may be because of your machine's speed or it might be a poorly-written query. I would do some investigating to figure out where the bottleneck is.
@@IAmTimCorey thanks I'll do that. The query is a simple select on a 5 row table. I'll try starting the sql server prior to run and see if that makes a difference
Hi, Tim. Apologies for this not being related to the video, but what are your thoughts on doing a video about reflection? I think I get the general idea but the finer details and necessity of it somewhat escapes me. Apologies if you've already made something on the topic, I didn't find anything.
In the other video you did "Blazor Server Side ..." you used services.AddTransient(); instead singleton like in this vid. I know the difference, but wonder what reason there might be to use one other another. P.S i use cosmos if this might change anything. And thank you very much for your vids.
tnx alot for your work i am learning alot from you i want to ask you some questions. betwwen sql server and oracle sql itch one is more secured and stronger and please can you make videos about azure key vault or how to build security around dotnet application(web desk) and will you cover MAUI when it will be available and is it cross platdorm (compile it once and run the app on linx mac and windows or it will be like wpf and winform only for windows) and will you make mobile app dev in the future?
I recently discovered your channel and really appreciate your work! But i had a few question relating to this section: 43:33 Why doesn't it work in blazor web assembly version? Is it because it compiles to web assembly and web assembly just can't? Also, is there any way to do it another way then? I understand that, even if it would work it woult be very bad practice (even if it WOULD work) to call the database client side, don't get me wrong.
WebAssembly runs fully on the client side. That means that the client can fully view our code. So, we cannot put any secrets in our code. That's why we don't access secure databases (just caching databases) from WebAssembly. Instead, we use APIs as an intermediary.
Thank you so much Mr. Corey! But I’ve got an issue. I am using .NET 6.0 (Long-term support) and I figured how to deal with Program.cs instead of missing Startup.cs but CRUD buttons are not working in a situation similar to the one you had and developer’s panel tells me that connection should be opened and valid. Thus I added connection.Open(); to methods in your library and now it works but still it gives me errors sometimes telling that another read operation is in progress or something like this. So I want to ask you if you didn’t forgot to add connection.Open(); line in your SaveData and LoadData methods of DataAccess library or maybe I am doing something wrong? Without this line it just doesn’t work at all.
At 18:10, if you look at lines 15 and 25, those lines are actually creating the connection to the database. You don't need to call open. to get this to work. If you call open, it will probably cause an issue. Also, in your case, it sounds like you are opening a connection and not closing it. That's a major issue, since that causes long-term issues for your database. I'm not sure what version of .NET this code was built upon, but this code works for all .NET versions from .NET Core 3.1 through .NET 7. So if it is having an issue, it is probably a small detail you missed.
@@IAmTimCorey thank you for the response, sir! I found an answer to my question. Some guy in the comments had exactly the same issue and you wrote him that he need to add await instead of return in SaveData method. For some reason code does not hit the end of Using. I did like you wrote by adding await and now it works fine.
I don't have a MySQL course. However, don't get too stuck on "with MVC" since the UI should not have any affect on the database used and the data access code from a Blazor Server project or WPF project should work the same in an MVC application. I cover that in more depth here: th-cam.com/video/24iujm49y10/w-d-xo.html
I believe you are asking about my method that returns data from the database. Right now, it is a List. If I want to return one record, I still return a List because then I can use the same method. However, if you want to lock into returning just one item and you don't want to return a list, just create a wrapper method that makes the "normal" call and then gets the returned List and pulls out the first record (or default if none) and returns it.
You’d mentioned adding the models to the library would it be better to do that as well as have classes with methods in library for the save/load ie _data.people.savedata(person) or _data.people.update(person) ? With the sql and connection string all in the library?
I do have quite a few videos on Azure in some form or another: th-cam.com/users/IAmTimCoreysearch?query=azure Some of these are for Azure DevOps but I also deploy to Azure Web Apps, use Azure SQL, and set up Azure Functions.
@@IAmTimCorey do you have a discord server? I'm learning c#. I like this language but there's so much to learn. This tutorial really helped me when i was just searching for a connection string that would work. Is there no way to find the connection string that you need? I also realized instead of using "user id=", you can also use "uid =" I was thinking if you can use "localhost" instead of 127.0.0.1
@@IAmTimCorey also, I use linux KDE neon as my main OS. I don't have that legacy of "visual studio" as it's not yet available on linux. So i use visual studio code. Do you even have a tutorial on entity Framework? And if yes, is it linux user-friendly tutorial? Like can you do it all on visual studio using dotnet CLI? Here's a request, can we do a whole Blazor project including restful API, UI, backend, database all being done using visual studio code, dotnet CLI?
what are the ways to learn C# and web development ? I was thinking about this question a lot. How to know c# well like other proffesionals, .. how they achieve that ? What's the path? (I saw roadmap here :D github[dot]com/MoienTajik/AspNetCore-Developer-Roadmap) I started learning c# in college at September 2019. I read a book basics of c#, done some exercises, went through a udemy course (intermediate, advanced C# with Mosh) and now I'm getting to Events in C#. I bought a book called Mastering C# (Michael B. White) and I was really boring. I knew 70% of everything written there, no detailed information. - I think books are good for getting know about what's going on with the language - It's explaining how something works. - Tutorials are great for practise and they explain how something should be done. - And there are platforms for training the problem solving. (Codewars) But still I don't know a good effective resources. Could you give us some pieces of advice about How to learn C#, the path of developer, what books are needed to read to get understand how C# works (C# via CLR, maybe?). Should I learn .NET Framework or focus on new .net Core? Where are a good resources ? I would like to be a good web developer, that means I should learn C#, LINQ, Design principles, .NET core 3.1, Blazor, SQL lang + platforms, CSS, a little bit of JS framework (Vue should be the easiest), code refactoring and then I would be ready to start producing some nice web apps ! but how to achieve that? - read books (which ones please ?) - go through some tutorials/courses (probably udemy, yt, etc.?) - practise what I learn (make a small website?) What an intermediate developer should go through to become a pro like you ? How to jump up to the next level ? thank you all for reading this and thinking about it. I would be really happy to get some replies from you.
This is the place to start for all C# developers: th-cam.com/video/LUv20QxXjfw/w-d-xo.html I'll be covering more in my upcoming Dev Questions series soon.
Design question: In a live scenario, would you strip all of that specific data logic(i.e. People Model, query, params, call to dataAccessor) out of the blazor page and into, for example another class Library or seperate folder within the Web project?
That's a good thing to consider. In this case, no, it is not vulnerable to SQL injection. SQL injection is when you allow the user to impact the query string in an unsafe way. For instance, providing input that would terminate the query early and potentially run a new query such as "select * from People where FirstName='%';Drop table Person;" or something like that. In our case, we are not asking for user input so our queries cannot be manipulated like that. Also, even if we did ask for user input, we are using query parameters (the "@FirstName", etc.) This allows us to place the contents of what the user gives us into the query properly and reduces the possibilities that they can pass in code to disrupt our SQL statement. However, we should still be cautious to clean the data from the user before accepting it to be doubly certain we get good data.
Nice demo. Although, all the cool kids are using MariaDB. :) Would it make more sense to handle the connection string in your injection so you don't have to deal with that in the UI code?
Potentially but that means you need to have a uniform way of accessing it. If some clients use IConfiguration and others don't, that would cause an issue in your class library. This way was simple and will work for any number of UIs.
Hi Tim. thanks to yuo i'm using dapper and loving it. I have to change a blazor server app to blazor client. Every thing wen ok until i started to connect to mysql. In server everything its ok. In blazor client the mysql driver threw an exception in any operation even when i open te connection. ¿Have you use blazor client with mysql? its that posiible?. Thans in advance
Blazor WebAssembly runs fully on the client side. That means that your C# code goes to the client. The client can read all of your source code (this is the same way Angular, React, and Vue work). That means that we do not want to put any sensitive information in our code, including connection strings, nor do we want to give direct access to our database. That is why we use an API with any client-side application like Blazor WebAssembly or React.
you mentioned at the beginning of this video that you use Blazor server for calling mysel. as you cannot call to mysql from blazor webassembly as you said. my question is then what solution would you use to call to a backend like mysql from a blazor webassembly app?
Hey Tim, I've recently started working on a project that uses blazor. So far I'm having difficulties connecting the WebApp to a local sql db. Documentation and tutorials, even this video have not enabled me to figure it out. I was wondering if you had some advice? Kind regards. Extra Info: Using .NET 6 & VS 2022 Blazor WASM + ASP.NET Core Hosting + WPA Currently in early development fase => trying to use local SQL Server (SSMS) since I've been given a replica from an existing database
This depends on what you mean. You can definitely connect your ASP.NET Core Hosting project to a local SQL database if that local SQL database is local to the web server that you are running on (meaning the same machine). You cannot access a local SQL database from another machine (at least not easily - you would need to open multiple firewall ports and use the IP address of the server). So if you are doing things on the same machine, just check your connection string. That's probably the problem.
I am using this video to learn Dapper CRUD actions, but using a wpf .net Core application to test instead (I want to get the data layer down first). When using the connection.ExecuteAsync method I get an "Invalid operation. The connection is closed." exception. I noticed this problem goes away when I change the "using IDbConnection connection = xxx" to "IDbConnection connection = xxx" . It seems the async operation is closing the connection before the actual execution is complete. monitoring the sp_who in SQL Server Management Studio, I can see that removing the using portion of the statement does not leave any hanging open connections. Is this still dangerous practice, and is there some sort of special case with the a desktop application vs a blazor server app? Thanks for your videos they're great! edit: forgot to mention the using portion works fine for loading data, it is only the executing of queries that gives me the closed connection exception. I suspect this is because the LoadData function awaits the connection.QueryAsync and the SaveData does not await anything, just returns the task. thanks again!
I've not come across this issue when using async. That's odd. I agree with your hypothesis. It is concerning that the using statement is closing before it is done. I'm guessing I should have done an await on the SaveData. You will need to await the task so that it completes before the statement is closed. So if the insert takes too long (meaning it doesn't complete before the next line), it will close the connection. My code probably has the bug. The using statement should not be closed before the operation completes.
I see. Would you recommend structuring the methods to return Task with no using method, or changing all the methods to async voids and use the using method? Followup question for my own education, if I'm seeing no hanging connections in the SQL Management Studio what are the real dangers of not making sure to utilize the using statement? edit: I decided to play it safe regardless and just changed all of the offending methods to async voids or async tasks and added awaits and put the using statements back in
Hello Tim, Thank you for a great video, I am currently working on a project and this helped me lots however at 47:20 you mention the use of Insert Form, I am struggling with that topic and merging it with searching MySQL DB. Would you have a video that make sense on how to add the search option using insert form? I have already created the whole page using Bootstrap, I just cannot link the input text to the "where" in my "select" command.
To add a where clause, you would do something like this: "select * from people where LastName = @LastName" and then pass in a LastName parameter (like we passed parameters into the insert statement). You would call the LoadData instead of the SaveData though.
@@IAmTimCorey Thank you for the fast reply. My main issue is how to I get the string from the input box I created to XXXX below. people = await _data.LoadData(sql, new { LastName = XXXX }, _config.GetConnectionString("defautl")); I have been searching everywhere online but I get so many different results that I just don't understand. My inputbox code looks like this: and the button looks as below: Search
A way to improve on this is to use stored procedures so you can have only certain stored procedures for different database users. But to do that with the minimum user permissions (GRANT EXECUTE ON PROCEDURE dbName.spName TO 'databaseUser'@'address';) you have to use MySqlConnector, a community MySql connector that fixes known issues in the official MySql.Data. I've been using this for my projects after I addapted the data access class from the TimCo Retail Manager and it's been working great. Also a question for Tim, I'm trying to change the database used in asp.net web apps for authentication to MySql from MSSql. I thought this might be "easy", as in change the connection string, import the necessary libraries for using MySql with entity framework, a few config changes and then let entity framework be in charge of building, modifying and queering the information as the loggin/authorization endpoints made by default that use the entity framework connection are probably more secure than what I'd be able to make. As of right now I've managed to avoid it crashing on startup of the web app but when I call the Api it fails to create the database on the first insertion (like it does when you don't have a database instantiated in MSSql). Any ideas for using entity framework with MySql? I've thought of manually creating carbon copies of the tables in the users database in MySql but don't know if there are any stored procedures/views that entity framework creates when using MSSql that it also uses.
My guess is that it has something to do with the data types in SQL vs MySQL but I am not sure. Working to change the Identity system can be a tricky business.
Thanks Tim, even though its a demo but I still think SaveData method could be improved even more, like execute extension method from dapper returns int which is rows affected for the execution, so that I think instead of Void or Task which they are fire and forget you could use int or bool var rowsAffected = connection.Execute(..); return rowsAffected > 0; by any chance it will be great to see a video from you about CQRS as well.
Please Mr Tim can you do the difference between Java vs C# and ASP.Net Core vs Spring Boot. Because Ever seen i came across with your tutorial .. I do say am in love with it.. The way you break things down am a Java desktop developer .. but i want you to tell me the advantage of going to moving to .net.. because some people still say Java is still the best Spring boot is far more better that Java is the king of enterprise .. and its really confusing me ..Please great mentor
I'm now at section "Dependency injection (startup.cs)" but there is no startup.cs in my BlazorServer project? Where to put the injection now? I try to put it in program.cs where the WeatherForecastService is
If you are using Blazor Server, it sounds like you are using the new .NET 6 Blazor Server. If you use the Blazor Server from .NET 5 you would see the Startup.cs. No worries, though, since you figured out the correct place to put the code.
Hi sir, I have a windowsforms app build with C#, it connects with a MySql database to store and retrieve data, I use Mysql.data for that, it actually runs on local host where the database exists too. But every time I need the app, I need to run XAMPP first so that I can connect to the database. Is there a way to connect to the database directly from the app without using any extra software? Thanks for your great content 💙
@@IAmTimCorey Thanks for your replay sir 🌹 What I mean is: now, my customer needs to install XAMPP in addition to the software I wrote, and every time he reboots his system, he needs to deal with an extra program -wich is XAMPP again- which kinda doesn't make sense for him.. Is there a way to create and run a MySql server with my C# code (maybe a library or a custom package) so that I don't need to use an external software? Thanks again 🌹
Thank you Tim. It will be so nice if you can provide an tutorial / payed course on how to deploy simple .net web app / web api but on a shared hosting like goDady...because aws / azure are so expensive..for example, i want to build an blog with custom cms..and winforms admin app...and i will buy your full timco retail manager course wery soon...but i cannot deploy my small / beginer level apps on azure...so, i am ready to pay some course on how to deploy 'timco like' apps on a shared hosting. I think that course would be awesome...
hello, is it possible to pull mobile data with this method? Is the mobile data extraction method different? I'm trying to make a mobile application, I'm new. Thank you from now
Hi @IAmTimCorey. Is it possible to use Dapper instead of EF for Microsoft.Identity and remove all EF-Packages from Blazor-Serverproject? And a small Hint, on 19:07 you made a Reference to your Classlib. With the new Visual Studio, you can drag the Projectname (in this case DataLibrary) and drop it directly on the Entry "Dependencies". In case you not already know it. Your Videos are great and a big inspiration in my daylie works *thumbUp
is there a good way to implement dependency injection in backend, I was halfway implementing Dependency injection in a web api controller before realizing I've never actually used dependency injection where there wasn't razor components... how does one do that? googling didn't do much for me
Because every page is a component (and we treat them that way). It sounds clean to separate them but the separation has more chance to confuse rather than clarify.
This isn't EF. It isn't leaving a connection to the data open and it isn't writing the query before making the call. The data is already on the local machine. Converting it to a list will give us more options to work with the data.
It depends on the database, but usually you get something like Scope_Identity() (this is for SQL), etc. Then you either return that in a select statement or you return it as a output parameter. Here is an example of how to do that: th-cam.com/video/eKkh5Xm0OlU/w-d-xo.html
dude i searched the internet for so long and finally i got to the right place. Man, if any out there is watching this, dude you are at the right place. Mr. tim corey keep up the good work.
I am glad it was helpful.
Between TH-cam and my IAmTimCorey courses I’ve seen this process so many times... but Every time I learn a little more about constructors, classes, dapper, sql dev, using statements, mapping, etc... the understanding that this guy gives us is invaluable. This is something like khan academy for C# ... Believe it or not but you are watching one of the best parts of the internet. thank you man 🙏🏻
I am glad my content has been so helpful.
I truly agree with you here.
i realize it is pretty randomly asking but do anybody know of a good place to stream new series online ?
@Joseph Lewis try Flixzone. Just search on google for it =)
@Archer Samson yup, I have been using flixzone for since march myself :)
Thanks for the video, I had looked at other tutorials but none of them worked, until I found your channel.
I am glad it was so helpful.
I switched from .NET to Node a few months back and fell in love with VueJs/Node/TS... But there's no way I'm not taking full advantage of this tutorial to Make myself more valuable to employers. My eyes just lit up when I saw this. Thank you Tim!
You are welcome.
It's my favorite kind of tutorial: focused, not overbearing and contains new information. I like dapper and blazor server 😊
Glad you enjoy it!
This was brilliant! I've looked at so many videos trying to figure out how to do this but yours was concise, accurate and well presented. You made it look simple to use blazor with a database which is not always the case with other TH-cam tutorials. Thanks!
Thank you!
Totally agree, Tim never fails to accurately explain topics without leaving you confused
This is the first of your vids I've watched and I got say we'll done! Like Einstein said: If you can't explain it simply, you don't understand it well enough. I've been struggling with this topic for a few days and your tutorial has cleared up everything for me!
I am glad it was helpful.
I just figured out how many lines of code I have needlessly written in recent months while working with MySql myself...
On the other side you just saved me from wasting even more time and space in the future. I need to do some refactoring this week.
Thanks.
Glad it helped.
Thank you, very helpful video, 29:36 - you can wait for it like this List rows = (await connection.QueryAsync(sql,parameters)).ToList();
Yep. I just find it easier to separate it into two steps because it makes debugging easier.
Awesome tutorial, very simple & sweet language
Successfully created demo by watching this video without any error or bug
Thank you so much
Thanks for growing your skills with this video.
Hey Tim. I actually learned to code using your WinForms videos. I took that knowledge and learned Node & Vue and I'm launching a product in the coming weeks which is over 2,000+ hours of code deep but I consider C# and .NET to be imperative to my general 'computer science' understanding. This video has been on my 'todo' list for nostalgia's sake although I don't get to play with C# much these days, I needed a day off from my project and thought this tutorial would help me unwind.
I managed to modify the code a bit and connect to my production server/database and I added appsettings.json to .gitignore. Now I have a great template for Blazor/MySQL which can be a lot of fun in the future. Blazor actually feels like a mix of React & Vue which is pretty cool because I like both.
I've noticed a trend that a lot of .NET developers eventually gravitate to Angular. I'm sure as people get more comfortable with Blazor that will change but I've always wondered why .NET devs tend to gravitate to Angular. I've seen it more than a handful of times. Is it that Angular has more of an 'Enterprise' feel than it's counterparts? Just wondering your take on that.
I am glad my videos have been so helpful. As to why people seem to gravitate towards Angular from .NET, I'm not sure. It may be a market thing. They see Angular jobs and they start pursuing what is more prevalent to them.
Big thank you from me. I needed exactly this for my project and you uploaded this video on the exact same day. I was really frustrated, that I wasn't able to find something good and then you uploaded your video.
Glad it helped!
I had trouble with the DELETE - permission problem. In MySQL workbench, used Edit / Preferences / SQLEditor - bottom of page uncheck 'Safe Updates (rejects UPDATES....)'.
Then worked OK. You did mention in the video there could have been a problem at this point.
As always, great video. Best regards. Jan.
I am glad you figured it out.
been looking for a while on a lot of places and this one was the most helpful and straight video i found. Thanks!
Excellent!
Wow, great tutorial. I have been working/learning EF core for the past couple months. After a series of complex error messages and struggling to do even basic things, I've decided to move to Dapper finally. I should have listened to you earlier lol
Thanks for sharing! I hope Dapper works better for you
0:29 "My goal isn't to entertain you. My goal is to turn you into a world-class developer" - Well, imo you manage to do both at the same time. You educate us in an entertaining way and explain very clear. Really good job.
Could you also make a video how to access multiple SQL 'types' such as TSql, MySql, Sqlite in the same project without using an external framework (e.g. because you aren't allowed to), but with the default classes instead? You know, SqlConnection, MySqlConnection, DbConnction, SqlCommand, MySqlCommand, DbCommand, etc...
Or if that's too much, a simple video about the Managed Extensibility Framework would help as well. I'm really stuck with that.
Not sure if Dapper qualifies as an "external framework" but the C# Application from Start to Finish course does something like this - it sets up both SQL data access and Text file data access and allows you to choose between the two via a toggle. I'll add your vote for MEF to the list.
Wonderful video from which I learned so much. Thank you Tim Corey for your effort!
You are welcome.
Simply Amazing !!!! I use the same steps to connect my application to the Oracle database. Hats off !!!
Great 👍
Hi Tim cory! i want you to talk about cross cutting and Aspect oriented prgramming with c#, how to handle it, best practices, thanks
Thanks for the suggestion.
@@IAmTimCorey thanks i hope you will consider my request
Awesome video Tim, as always. Would love to see you take this topic a little further by using some forms for data input and data grids for displaying the data back please. Keep up the great work!
Maybe that will come in a complete application series.
Keep up the good work you're amazing! I can't seem to get my head around C# until I discovered your channel!
Welcome aboard!
50:00 when ever I create an update statement I always type "Update set where" and then go back and edit what ever I need for that to work. That way I never miss the 'where' and overwrite the whole table since if I was to try and run it with "update person set firstname='bob' where" the query will fail since there is not value set after where. I little tip I got from a colleague at my first developer job. Kind stuck with me and since I've taught others to do the same.
I normally don't use delete that much in my day to day work but you could use that tip for delete queries aswell "delete from where" and continue from there.
Thanks for sharing.
I’ll go you one better. I *always* write UPDATE statements as SELECT using my WHERE clause first. That way I get a visual check on the records affected by the UPDATE.
@@bunkie2100 I never really got the hang of it that way. I guess I just need to try it for a longer period. I see the benefits of it. I see some of my colleagues do it that way too. I have usually already made a select statement beforehand so I know the result.
First: scheduled to watch tomorrow early morning. NZ thx in advance Tim.
You are welcome.
Thanks for your video. Dapper seems much more easy to learn and implement than EF. Please can you also do a video showing how to display data in datagrid and how to generate Reports.
Thanks, added to the topics list.
Thank you IAmTimCorey! I was wondering. Can we execute a store procedure rather than write down our query?
For example:
Datable g = access.getPeople();
I felt the temptation, but you went for that Interface, nice.
Glad you enjoyed it.
Hi Tim, I watched other video of yours and got wiser by them. I see that this video was created 4 years ago. Do you think it is still current today?
There will be slight differences, but most of the code will be exactly the same today.
Thanks for all your video Tim, and also thank you for your clear diction. English is not my birth language therefore I can perfectly understand you.
You are very welcome
well thought through and well explained. i like it a lot and learn to see things come together at the same time. thanks for this talk.
You are welcome.
Hello Sir, thank you for this video! I am currently in the process of learning how to develop Blazor server applications and I have been able to make some progress by implementing basic CRUD operations. However, I am concerned about the security implications of passing IDs to another page without using local storage. Is there a recommended method for achieving this? , do you have any instructional videos on this topic that you can recommend?
Local storage isn't going to increase your security here. That is fully available to the client to manipulate. You need to do security checks on each page and for each action anyway, so passing IDs isn't a security risk.
wow a 3 years old tutorial that still works
👍
This is awesome. Thanks. :)
I love the tooling MS giving us. It has everything included and core apps can be run on Linux machines, but the MS SQL Server is the only limiting factor. You can't really use it outside of Azure and it's too expensive for personal projects. The free tier isn't enough for real-world personal projects that would be alive over 12 months.
MS SQL is really good and would love to use it. Especially loved how you used database projects with TimCoRetailManager. I've searched, but couldn't find any way to use that for MySQL/Postgres. The only add-on I did find was dbForge Fusion for MySQL, but it costs like a $300. Can't really afford that for personal projects.
Well, for personal use, you can use SQL Server Developer Edition, which is free. There is also a version of Microsoft SQL that runs on Linux. Check out this video of running SQL on Docker (on Linux): th-cam.com/video/Yj69cWEG_Yo/w-d-xo.html
Exactly what I needed. Thank You very much!
Thanks for looking to Tim when you need help skilling up!
Thanks Tim for this video. I was building a project with EfCore with clean architecture, but wanted to refacter EfCore use with interfaces... looks like I can now use Dapper for reads and EfCore for writes if I get this right.
Why have two ORMs? Use Dapper for both.
Ah, right. Noted. But that now begets how to replace a dbcontex class and a migration rub in the program class that creates the db and applies a migration upon startup of the application. I guess that might be my suggestion for another video down the road. Of. Ourse, I think I can solve this with the previous Blazir video that was a couple of months ago that showed us a IDatabase interface.
Hi
Tim, thx for the video. Two questions, why not use ToListAsync() in LoadData ? It's because the overhead that come with async/await?
Correct. I did not see the async to be that valuable when the data was already on the machine. This call is valuable when you have an IQueriable where the ToList actually performs the call and downloads the data.
in the new vs2022 version is no startup.cs. where do i need to add the services? in program.cs it won' work
It will work in Program.cs. Here is a video on how to do it: th-cam.com/video/vdhFw1VSowg/w-d-xo.html
@@IAmTimCorey hi. Thx for answering. I tried it. I wrote the services.builder.........dataaccess line in the right place, and then the blazor app don't run anymore.
I can't find another reason, because, when I comment the line out, the app works.
When we publish a project with a data library what folders do we need to include on the server in order to execute the application? The publish process produces one release folder for the Data library and one for the blazor project, how does the blazor project access the data library? If you have any tutorials on migrating this to a linux vm please let me know, great video thank you for your thorough explanations.
Excellent as always Tim. I watched the Blazor Server with SQL access tutorial as well the other day. I noticed that on that one you created an entity(or model?) for the data access library together with the sqldataaccess class. Considering that both are Blazor Server project. Which one do you think is better in terms of design?
Also, when I run my app that connects to MSSQL DB it takes a long time to connect and show the list of users, I changed the access from transient to singleton hoping it would help but it didn't do much. Is this to be expected because MSSQL is not started and is being started by visual studio whenever it tries to run? If so then I think this shouldn't be a problem on a web app uploaded on cloud servers since SQL Server should always be up, am I correct in this assumption?
Sorry for the long questions.
I am not sure what you are asking in the first question. As for the second question, it all depends on what you mean by a long time. The first time you talk to SQL, it will be a bit slower but it should not be slow. It may be because of your machine's speed or it might be a poorly-written query. I would do some investigating to figure out where the bottleneck is.
@@IAmTimCorey thanks I'll do that. The query is a simple select on a 5 row table. I'll try starting the sql server prior to run and see if that makes a difference
Hi, Tim. Apologies for this not being related to the video, but what are your thoughts on doing a video about reflection? I think I get the general idea but the finer details and necessity of it somewhat escapes me. Apologies if you've already made something on the topic, I didn't find anything.
I will add that suggestion to the list. Thanks.
Hi Tim, great content, off course!
In Blazor we don't use controller or "code behind" like razor pages?
Blazor uses the MVVM pattern.
timy u c sharp legend lol thanks alot
You are welcome.
Great videos and very practical. Would you have an example using Blazor+Dapper+Oracle?
I don't yet, no.
In the other video you did "Blazor Server Side ..." you used services.AddTransient(); instead singleton like in this vid. I know the difference, but wonder what reason there might be to use one other another. P.S i use cosmos if this might change anything.
And thank you very much for your vids.
tnx alot for your work i am learning alot from you i want to ask you some questions.
betwwen sql server and oracle sql itch one is more secured and stronger and please can you make videos about azure key vault or how to build security around dotnet application(web desk)
and will you cover MAUI when it will be available and is it cross platdorm (compile it once and run the app on linx mac and windows or it will be like wpf and winform only for windows) and will you make mobile app dev in the future?
SQL and Oracle are equally good at security. I'll add your suggestions to the list.
I recently discovered your channel and really appreciate your work!
But i had a few question relating to this section:
43:33 Why doesn't it work in blazor web assembly version?
Is it because it compiles to web assembly and web assembly just can't?
Also, is there any way to do it another way then?
I understand that, even if it would work it woult be very bad practice (even if it WOULD work) to call the database client side, don't get me wrong.
WebAssembly runs fully on the client side. That means that the client can fully view our code. So, we cannot put any secrets in our code. That's why we don't access secure databases (just caching databases) from WebAssembly. Instead, we use APIs as an intermediary.
I like your video. I have a question. Can changes be displayed directly on the web as the database changes? Ask me what to do.
You could do that with Blazor and some monitoring of the database, yes.
I love you tim.. You help a lot.
Thanks
Thank you for sharing the knowledge and doing it so well.
My pleasure!
Thank you so much Mr. Corey! But I’ve got an issue. I am using .NET 6.0 (Long-term support) and I figured how to deal with Program.cs instead of missing Startup.cs but CRUD buttons are not working in a situation similar to the one you had and developer’s panel tells me that connection should be opened and valid. Thus I added connection.Open(); to methods in your library and now it works but still it gives me errors sometimes telling that another read operation is in progress or something like this. So I want to ask you if you didn’t forgot to add connection.Open(); line in your SaveData and LoadData methods of DataAccess library or maybe I am doing something wrong? Without this line it just doesn’t work at all.
At 18:10, if you look at lines 15 and 25, those lines are actually creating the connection to the database. You don't need to call open. to get this to work. If you call open, it will probably cause an issue. Also, in your case, it sounds like you are opening a connection and not closing it. That's a major issue, since that causes long-term issues for your database.
I'm not sure what version of .NET this code was built upon, but this code works for all .NET versions from .NET Core 3.1 through .NET 7. So if it is having an issue, it is probably a small detail you missed.
@@IAmTimCorey thank you for the response, sir! I found an answer to my question. Some guy in the comments had exactly the same issue and you wrote him that he need to add await instead of return in SaveData method. For some reason code does not hit the end of Using. I did like you wrote by adding await and now it works fine.
Really helpful video. Thanks!
You're welcome!
Hi Tim!! Is there a course on your website for MySQL and C#? More specifically MVC?
I don't have a MySQL course. However, don't get too stuck on "with MVC" since the UI should not have any affect on the database used and the data access code from a Blazor Server project or WPF project should work the same in an MVC application. I cover that in more depth here: th-cam.com/video/24iujm49y10/w-d-xo.html
Superb as always Tim :)
Thanks!
Very informative. How about a tutorial on Sybase Central SQL Anywhere ? Have you tried to connect with Blazor? Thank you
I will add it to the list. Thanks for the suggestion.
Awesome video Tim, How to add method return single object
I believe you are asking about my method that returns data from the database. Right now, it is a List. If I want to return one record, I still return a List because then I can use the same method. However, if you want to lock into returning just one item and you don't want to return a list, just create a wrapper method that makes the "normal" call and then gets the returned List and pulls out the first record (or default if none) and returns it.
@@IAmTimCorey Thanks for the answer, you are right, ... can i use identity asp in Blazor with dapper without EF Core?
You’d mentioned adding the models to the library would it be better to do that as well as have classes with methods in library for the save/load ie _data.people.savedata(person) or _data.people.update(person) ? With the sql and connection string all in the library?
@Tim when u will going to put up some cloud videos(aws or azure) ..is it on ur list in this year?
I do have quite a few videos on Azure in some form or another: th-cam.com/users/IAmTimCoreysearch?query=azure
Some of these are for Azure DevOps but I also deploy to Azure Web Apps, use Azure SQL, and set up Azure Functions.
Very informative. How about a tutorial on MongoDB.
Here you go: th-cam.com/video/69WBy4MHYUw/w-d-xo.html
@@IAmTimCorey thanks
Thanks bro i have learned alot.
Glad to hear it.
Great video!,
I have a trivial question, how can I send an explicit long query string with JOIN etc.? , thanks
Just like you would with a select statement. I do not believe there is a length limit on your query.
I loved your tutorial.
Thanks!
@@IAmTimCorey do you have a discord server? I'm learning c#. I like this language but there's so much to learn. This tutorial really helped me when i was just searching for a connection string that would work. Is there no way to find the connection string that you need? I also realized instead of using "user id=", you can also use "uid ="
I was thinking if you can use "localhost" instead of 127.0.0.1
@@IAmTimCorey also, I use linux KDE neon as my main OS. I don't have that legacy of "visual studio" as it's not yet available on linux. So i use visual studio code. Do you even have a tutorial on entity Framework? And if yes, is it linux user-friendly tutorial?
Like can you do it all on visual studio using dotnet CLI?
Here's a request, can we do a whole Blazor project including restful API, UI, backend, database all being done using visual studio code, dotnet CLI?
what are the ways to learn C# and web development ?
I was thinking about this question a lot. How to know c# well like other proffesionals, .. how they achieve that ? What's the path? (I saw roadmap here :D github[dot]com/MoienTajik/AspNetCore-Developer-Roadmap)
I started learning c# in college at September 2019. I read a book basics of c#, done some exercises, went through a udemy course (intermediate, advanced C# with Mosh) and now I'm getting to Events in C#. I bought a book called Mastering C# (Michael B. White) and I was really boring. I knew 70% of everything written there, no detailed information.
- I think books are good for getting know about what's going on with the language - It's explaining how something works.
- Tutorials are great for practise and they explain how something should be done.
- And there are platforms for training the problem solving. (Codewars)
But still I don't know a good effective resources. Could you give us some pieces of advice about How to learn C#, the path of developer, what books are needed to read to get understand how C# works (C# via CLR, maybe?). Should I learn .NET Framework or focus on new .net Core?
Where are a good resources ?
I would like to be a good web developer, that means I should learn C#, LINQ, Design principles, .NET core 3.1, Blazor, SQL lang + platforms, CSS, a little bit of JS framework (Vue should be the easiest), code refactoring and then I would be ready to start producing some nice web apps !
but how to achieve that?
- read books (which ones please ?)
- go through some tutorials/courses (probably udemy, yt, etc.?)
- practise what I learn (make a small website?)
What an intermediate developer should go through to become a pro like you ? How to jump up to the next level ?
thank you all for reading this and thinking about it. I would be really happy to get some replies from you.
This is the place to start for all C# developers: th-cam.com/video/LUv20QxXjfw/w-d-xo.html I'll be covering more in my upcoming Dev Questions series soon.
@@IAmTimCorey thank you! i didn't know about this video!
Hi Tim, Thanks for you Videos.
Awesome
Do you have video about Authorized?
Not specifically, but see if these add value - th-cam.com/users/IAmTimCoreysearch?query=authent
Design question: In a live scenario, would you strip all of that specific data logic(i.e. People Model, query, params, call to dataAccessor) out of the blazor page and into, for example another class Library or seperate folder within the Web project?
It depends on the situation. This might be the same as what I would do in production or I might add a bit more separation.
@@IAmTimCorey gotcha. Thanks for the reply!
Just a newbie question. Does this method not prone to cyber-attacks like SQL Injection?
That's a good thing to consider. In this case, no, it is not vulnerable to SQL injection. SQL injection is when you allow the user to impact the query string in an unsafe way. For instance, providing input that would terminate the query early and potentially run a new query such as "select * from People where FirstName='%';Drop table Person;" or something like that. In our case, we are not asking for user input so our queries cannot be manipulated like that. Also, even if we did ask for user input, we are using query parameters (the "@FirstName", etc.) This allows us to place the contents of what the user gives us into the query properly and reduces the possibilities that they can pass in code to disrupt our SQL statement. However, we should still be cautious to clean the data from the user before accepting it to be doubly certain we get good data.
@@IAmTimCorey I see. Thank you. I am learning a lot from you.
Yes this is what I'm looking for
Glad to hear it.
Nice demo.
Although, all the cool kids are using MariaDB. :)
Would it make more sense to handle the connection string in your injection so you don't have to deal with that in the UI code?
Potentially but that means you need to have a uniform way of accessing it. If some clients use IConfiguration and others don't, that would cause an issue in your class library. This way was simple and will work for any number of UIs.
Hi Tim. thanks to yuo i'm using dapper and loving it. I have to change a blazor server app to blazor client. Every thing wen ok until i started to connect to mysql. In server everything its ok. In blazor client the mysql driver threw an exception in any operation even when i open te connection. ¿Have you use blazor client with mysql? its that posiible?. Thans in advance
Blazor WebAssembly runs fully on the client side. That means that your C# code goes to the client. The client can read all of your source code (this is the same way Angular, React, and Vue work). That means that we do not want to put any sensitive information in our code, including connection strings, nor do we want to give direct access to our database. That is why we use an API with any client-side application like Blazor WebAssembly or React.
you mentioned at the beginning of this video that you use Blazor server for calling mysel. as you cannot call to mysql from blazor webassembly as you said. my question is then what solution would you use to call to a backend like mysql from a blazor webassembly app?
You would put an API in between.
@@IAmTimCorey Thanks!
Hello Tim, Can put a separate video connecting to Oracle Database Stored procedure with UDT
I will add it to the list. Thanks for the suggestion.
Thank you Tim
You are welcome.
Hey Tim, I've recently started working on a project that uses blazor.
So far I'm having difficulties connecting the WebApp to a local sql db.
Documentation and tutorials, even this video have not enabled me to figure it out.
I was wondering if you had some advice?
Kind regards.
Extra Info:
Using .NET 6 & VS 2022
Blazor WASM + ASP.NET Core Hosting + WPA
Currently in early development fase => trying to use local SQL Server (SSMS) since I've been given a replica from an existing database
This depends on what you mean. You can definitely connect your ASP.NET Core Hosting project to a local SQL database if that local SQL database is local to the web server that you are running on (meaning the same machine). You cannot access a local SQL database from another machine (at least not easily - you would need to open multiple firewall ports and use the IP address of the server). So if you are doing things on the same machine, just check your connection string. That's probably the problem.
I am using this video to learn Dapper CRUD actions, but using a wpf .net Core application to test instead (I want to get the data layer down first). When using the connection.ExecuteAsync method I get an "Invalid operation. The connection is closed." exception. I noticed this problem goes away when I change the "using IDbConnection connection = xxx" to "IDbConnection connection = xxx" . It seems the async operation is closing the connection before the actual execution is complete.
monitoring the sp_who in SQL Server Management Studio, I can see that removing the using portion of the statement does not leave any hanging open connections. Is this still dangerous practice, and is there some sort of special case with the a desktop application vs a blazor server app? Thanks for your videos they're great!
edit: forgot to mention the using portion works fine for loading data, it is only the executing of queries that gives me the closed connection exception. I suspect this is because the LoadData function awaits the connection.QueryAsync and the SaveData does not await anything, just returns the task. thanks again!
I've not come across this issue when using async. That's odd. I agree with your hypothesis. It is concerning that the using statement is closing before it is done. I'm guessing I should have done an await on the SaveData. You will need to await the task so that it completes before the statement is closed. So if the insert takes too long (meaning it doesn't complete before the next line), it will close the connection. My code probably has the bug. The using statement should not be closed before the operation completes.
I see. Would you recommend structuring the methods to return Task with no using method, or changing all the methods to async voids and use the using method?
Followup question for my own education, if I'm seeing no hanging connections in the SQL Management Studio what are the real dangers of not making sure to utilize the using statement?
edit: I decided to play it safe regardless and just changed all of the offending methods to async voids or async tasks and added awaits and put the using statements back in
is this video series include client server (API) sample project version?
What video series? This is a stand-alone video covering MySQL in Blazor Server.
thank you, Tim
You are welcome.
Thanks, just what I needed.
Glad I could help!
YOU SAVE LIFES
Thanks!
Thanks Tim for the tutorial? How about using MySQL with EntityFramework? Can you also do a video on tht?
Probably not. I don't cover EF since I don't think it is nearly as useful as people think it is.
Hello Tim,
Thank you for a great video, I am currently working on a project and this helped me lots however at 47:20 you mention the use of Insert Form, I am struggling with that topic and merging it with searching MySQL DB.
Would you have a video that make sense on how to add the search option using insert form?
I have already created the whole page using Bootstrap, I just cannot link the input text to the "where" in my "select" command.
To add a where clause, you would do something like this: "select * from people where LastName = @LastName" and then pass in a LastName parameter (like we passed parameters into the insert statement). You would call the LoadData instead of the SaveData though.
@@IAmTimCorey Thank you for the fast reply.
My main issue is how to I get the string from the input box I created to XXXX below.
people = await _data.LoadData(sql, new { LastName = XXXX }, _config.GetConnectionString("defautl"));
I have been searching everywhere online but I get so many different results that I just don't understand.
My inputbox code looks like this:
and the button looks as below:
Search
Many thanks sir!
You are welcome.
can you make a video of one to many relationship with one tablet fields include an other table fields
Thanks for the suggestion. Please add it to the list on the suggestion site so others can vote on it as well: suggestions.iamtimcorey.com/
May I ask what software you use to screenshot/zoom in and edit?
Tim did a video on this. th-cam.com/video/PJGSTLwl2nA/w-d-xo.html
Specifically, I use Zoom It by SysInternals: docs.microsoft.com/en-us/sysinternals/
A way to improve on this is to use stored procedures so you can have only certain stored procedures for different database users. But to do that with the minimum user permissions (GRANT EXECUTE ON PROCEDURE dbName.spName TO 'databaseUser'@'address';) you have to use MySqlConnector, a community MySql connector that fixes known issues in the official MySql.Data.
I've been using this for my projects after I addapted the data access class from the TimCo Retail Manager and it's been working great.
Also a question for Tim, I'm trying to change the database used in asp.net web apps for authentication to MySql from MSSql. I thought this might be "easy", as in change the connection string, import the necessary libraries for using MySql with entity framework, a few config changes and then let entity framework be in charge of building, modifying and queering the information as the loggin/authorization endpoints made by default that use the entity framework connection are probably more secure than what I'd be able to make. As of right now I've managed to avoid it crashing on startup of the web app but when I call the Api it fails to create the database on the first insertion (like it does when you don't have a database instantiated in MSSql). Any ideas for using entity framework with MySql? I've thought of manually creating carbon copies of the tables in the users database in MySql but don't know if there are any stored procedures/views that entity framework creates when using MSSql that it also uses.
My guess is that it has something to do with the data types in SQL vs MySQL but I am not sure. Working to change the Identity system can be a tricky business.
Thanks Tim, even though its a demo but I still think SaveData method could be improved even more, like execute extension method from dapper returns int
which is rows affected for the execution, so that I think instead of Void or Task which they are fire and forget you could use int or bool
var rowsAffected = connection.Execute(..);
return rowsAffected > 0;
by any chance it will be great to see a video from you about CQRS as well.
Yep, you could do that.
Please Mr Tim can you do the difference between Java vs C# and ASP.Net Core vs Spring Boot. Because Ever seen i came across with your tutorial .. I do say am in love with it.. The way you break things down am a Java desktop developer .. but i want you to tell me the advantage of going to moving to .net.. because some people still say Java is still the best Spring boot is far more better that Java is the king of enterprise .. and its really confusing me ..Please great mentor
I can add that to the suggestion list. There is a lot of preference in these decisions, though, as well.
@@IAmTimCorey Thanks Mentor
Very useful thank you 🙏
You are welcome.
do you have a tutorial on how to make crud in blazor calling API?
Not yet, no.
ArgumentException: Format of the initialization string does not conform to specification starting at index 54
I'm now at section "Dependency injection (startup.cs)" but there is no startup.cs in my BlazorServer project? Where to put the injection now? I try to put it in program.cs where the WeatherForecastService is
If you are using Blazor Server, it sounds like you are using the new .NET 6 Blazor Server. If you use the Blazor Server from .NET 5 you would see the Startup.cs. No worries, though, since you figured out the correct place to put the code.
@@IAmTimCorey Thank you. You are completely correct is is NET 6 and Server.
Hi sir, I have a windowsforms app build with C#, it connects with a MySql database to store and retrieve data, I use Mysql.data for that, it actually runs on local host where the database exists too. But every time I need the app, I need to run XAMPP first so that I can connect to the database. Is there a way to connect to the database directly from the app without using any extra software?
Thanks for your great content 💙
As long as your MySQL server is still running, you can connect to it directly, like I did, instead of having all of XAMPP running.
@@IAmTimCorey Thanks for your replay sir 🌹
What I mean is: now, my customer needs to install XAMPP in addition to the software I wrote, and every time he reboots his system, he needs to deal with an extra program -wich is XAMPP again- which kinda doesn't make sense for him..
Is there a way to create and run a MySql server with my C# code (maybe a library or a custom package) so that I don't need to use an external software?
Thanks again 🌹
Not MySQL, no, but check out SQLite. It can be self-contained rather than needing a database engine to power it.
@@IAmTimCorey Thanks a lot 🌹
Thank you Tim. It will be so nice if you can provide an tutorial / payed course on how to deploy simple .net web app / web api but on a shared hosting like goDady...because aws / azure are so expensive..for example, i want to build an blog with custom cms..and winforms admin app...and i will buy your full timco retail manager course wery soon...but i cannot deploy my small / beginer level apps on azure...so, i am ready to pay some course on how to deploy 'timco like' apps on a shared hosting. I think that course would be awesome...
I will add it to the list. Thanks for the suggestion.
hello, is it possible to pull mobile data with this method? Is the mobile data extraction method different? I'm trying to make a mobile application, I'm new. Thank you from now
Mobile is different because the connection string cannot be private, so you will need to use an API.
Hi @IAmTimCorey. Is it possible to use Dapper instead of EF for Microsoft.Identity and remove all EF-Packages from Blazor-Serverproject? And a small Hint, on 19:07 you made a Reference to your Classlib. With the new Visual Studio, you can drag the Projectname (in this case DataLibrary) and drop it directly on the Entry "Dependencies". In case you not already know it. Your Videos are great and a big inspiration in my daylie works *thumbUp
It isn't easy, no. I recommend leaving it with EF, even though I'm not an EF fan. Thanks for the tip and the encouraging words.
is there a good way to implement dependency injection in backend, I was halfway implementing Dependency injection in a web api controller before realizing I've never actually used dependency injection where there wasn't razor components... how does one do that? googling didn't do much for me
Check out the TimCo Retail Manager series. In it, we implement dependency injection in our API once we upgrade it to .NET Core.
Does this approach works with Blazor Web Assembly app and a MySQL database locally hosted on xampp ?
No, it’s still a web application. That wouldn’t be secure.
19:30: It will be more cleary and clean if we create a folder "Components" and "Pages"? Why you mix components and pages in same folder "Pages"?
Because every page is a component (and we treat them that way). It sounds clean to separate them but the separation has more chance to confuse rather than clarify.
@@IAmTimCorey i see. Thx Tim!
how to solve this problem at connectionString ?
error : The option 'IntegratedSecurity' is not currently supported.
You would need to remove the unsupported parameter. You can use this site to help you form a proper connection string: www.connectionstrings.com/
Why using List for the return of LoadData instead of IQueryable ? It seem really more expensive for not that much use
This isn't EF. It isn't leaving a connection to the data open and it isn't writing the query before making the call. The data is already on the local machine. Converting it to a list will give us more options to work with the data.
Hey! I couldn't find startup.cs file in my latest BlazorServer app. Can you help how to do Dependency injection at 21:27?
Here you go: th-cam.com/video/vdhFw1VSowg/w-d-xo.html
How would you get the last inserted id when you add something to the database with dapper?
It depends on the database, but usually you get something like Scope_Identity() (this is for SQL), etc. Then you either return that in a select statement or you return it as a output parameter. Here is an example of how to do that: th-cam.com/video/eKkh5Xm0OlU/w-d-xo.html
What is the mod / extension you are using to auto complete using statements?
That's just Visual Studio. No mods or extensions.
@@IAmTimCorey Thank you. I must have missed a setting. Still new to this.