Connecting C# To MySQL Using Blazor (Full CRUD Actions)

preview_player
Показать описание
How do I talk to MySQL from C#? That's a pretty common question. MySQL databases are very popular, especially on the web. So when you are building a web application especially, you might be considering using MySQL. Fortunately, there is a very easy way to connect to MySQL databases using C# and in this video, I am going to show you how to do just that.

0:00 - Intro
0:51 - Demo Blazor Server App
3:57 - Adding a Class Library
5:43 - Adding NuGet packages
7:04 - Data Access class:
8:27 - • Load data method explained
15:51 - • Save data method explained
18:20 - Library dependency
19:15 - New Blazer page
24:38 - Razor page setup: Using statements
25:45 - Making data access methods Async
32:25 - Adding Data Models
34:11 - Razor Page setup: Calling data access
37:19 - MySQL Connection string
41:11 - Razor Page layout for displaying data
44:11 - Save Data
49:14 - Update Data
52:40 - Delete Data
54:55 - Summary and concluding remarks

Thanks to Ralfs HBK for the chapters breakdown
Рекомендации по теме
Комментарии
Автор

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.

manuthpemmawadu
Автор

Between YouTube 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 🙏🏻

dickybird
Автор

Thanks for the video, I had looked at other tutorials but none of them worked, until I found your channel.

kristianrincon
Автор

Thank you, very helpful video, 29:36 - you can wait for it like this List<T> rows = (await connection.QueryAsync<T>(sql, parameters)).ToList();

kent
Автор

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!

bobDotJS
Автор

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 YouTube tutorials. Thanks!

HemmingEducation
Автор

It's my favorite kind of tutorial: focused, not overbearing and contains new information. I like dapper and blazor server 😊

zoltan.halasz
Автор

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.

hory-portier
Автор

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!

garethcairncross
Автор

Awesome tutorial, very simple & sweet language
Successfully created demo by watching this video without any error or bug
Thank you so much

annasahebrahane
Автор

been looking for a while on a lot of places and this one was the most helpful and straight video i found. Thanks!

MarcosJunior-mxjl
Автор

Wonderful video from which I learned so much. Thank you Tim Corey for your effort!

bohuang
Автор

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.

jankool
Автор

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.

bobDotJS
Автор

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.

johecht
Автор

Simply Amazing !!!! I use the same steps to connect my application to the Oracle database. Hats off !!!

wau
Автор

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.

CRBarchager
Автор

Exactly what I needed. Thank You very much!

TwoThre
Автор

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.

adamv
Автор

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

Bubinga
join shbcf.ru