ASP.NET MVC Data Access in C# - The complete data path from database to display and back

preview_player
Показать описание

Tutorials are excellent at teaching you about a piece of the overall development puzzle but sometimes you want to take a step back and look at the bigger picture. That way you can see where those puzzle pieces you have been collecting fit into place. This video is going to be that bigger picture overview. We are going to build a small demo of an MVC application and its accompanying database. We will set up a form to collect data, capture that data, and put it into our database. We will then get that data back out of our database and display it on another form. The goal is to show the data access process from beginning to end in ASP.NET MVC. This won't be a full application and we won't complete the full process, since we won't be putting this in source control, we won't be deploying this application, and we won't be setting up authentication.

0:00 - Intro
1:13 - Creating ASP .NET Framework app
4:35 - Adding MVC data Model
6:20 - Sign-up form: new MVC Controller action and View with "create" template
12:56 - Signup-form configuration and validation: data Model annotations
23:41 - Crude sign-up form: Html.EditorForModel()
25:27 - Sign-up from code walkthrough
27:53 - Posted data validation: Controller POST action
32:43 - Posted data storage: Database table design
38:15 - Posted data storage: Database connection string
40:00 - Data Model for database
43:39 - Data access with Dapper
52:09 - Data access Business Logic
59:40 - Storing posted data in Database
1:04:39 - Accessing and displaying data from database.
1:12:44 - Summary and concluding remarks

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

I'm a junior developer at a large company. I've been trying to build on this very complex QA application for weeks and feel like a fool for not seeing how the pieces are fitting together, connecting DB to backend to frontend, etc. Your deliberate, explicit instructions are helping me to document the MVC process in my own code and on Miro. This video is really helping me for my career. Thanks, Tim.

formerfatboy
Автор

While it is very evident that your quality of teaching is fabulous, your commitment and consistency in educating community of developers is amazing
I know it requires a lot of efforts to produce such long videos with best quality that too consistently. We all appreciate your contribution sir. Hope you be known to whole dot net community. God bless :)

vinuhosanagar
Автор

For those of you who are having issues with your database, here's some advice (after 1 week of listening to this video over and over again):

-> When you update your DB, make sure to publish it again
-> Put your Database and DataLibrary in the same folder as the MVC project to make things easier.
-> ConnectionString should be the exact DB that you're using. Make sure you copy and paste it right too.
-> Make sure when you call your DB, to tripple check the spelling (ex. dbo.Users not dbo.User)
-> Also, you might get errors using a Database named called "dbo.User". If so, either rename it or use "dbo.[User]" to fix your problem.

Good luck everyone! Google your mistakes and dont be afraidto try again and again on your project.

chrismtz
Автор

I watch your tutorials few days in a row now. Speechless, you are the best teacher I ever seen.

Arrato
Автор

0:00 Intro
1:14 Project setup
4:25 Implementing employee sign-up form
12:00 Adding requirements to employee form
23:10 Making a quick form with html.EditorForModel()
25:28 Understanding how the employee form works in SignUp.cshtml
27:54 Handling the employee form in HomeController.cs
32:45 Creating the Employee table
40:00 Creating the EmployeeModel class in DataLibrary
44:00 Using Dapper to interact with the database
52:09 Implementing the EmployeeProcessor class to handle the business logic
59:39 Using the EmployeeProcessor class to store employee data
1:04:22 Displaying employee data by using the EmployeeProcessor class
1:12:44 Ending review

jackfitzgerald
Автор

I can’t begin to tell you how helpful your videos are, in just over an hour you’ve helped me understand what it’s taken me all week at work to wrap my head around. I have so much of your content bookmarked. Thank you so much Tim

lukaskarlgerhard
Автор

You're an awesome instructor Tim.

gff
Автор

Every time when I watch your Tutorials, I find the actual logic how people work in software Companies. Thanks for Amazing videos.

fatimaajij
Автор

Thanks .. is there a .Net Core version?

aymanmetwally
Автор

For those struggling with an error saying Object reference not set to an instance of an object", check that your connection string is in the CORRECT web.config file. It SHOULD be in the Web.config below packages.config and Global.asax in your MVCApp project, NOT the one under views, shared, Web.config. This solved my problem =)

Hope this helps those who are struggling, because I sure as hell nearly pulled my hair out hahaha

OmniTato
Автор

I am having an issue with the LoadEmployees method in the employeeprocessor. my error is inconsistent accessibility and it claims that the return type is less accessible than the method. can you help me?

rokkrdude
Автор

Strange as it may sound - this video is symphony. I followed each line of code by coding it in parallel in VS2019 - taking time to savour the notes of logic, the melody of the architecture and the rhythm of the underlying logic as the whole application came together like a musical crescendo. Life is

madhavmehendale
Автор

I commend you for not even attempting to try to store passwords. I've stored passwords before and I never want to do it again.

VictorGarcia-siwy
Автор

I can't thank you enough Tim. I have been struggling for over 2 weeks to find how to do this, and you saved me! Thank you very much. Love you! Subscribed.

raduionita
Автор

public static int SaveData<T>(string sql, T data)
{
using (IDbConnection cnn = new
{
return cnn.Execute(sql, data);
}
}

Hi, Thanks for the tutorial.
I have tried to run the solution like at 1:02:38 but it gives me error on line "return cnn.Execute(sql, data); " saying that there is an Incorrect syntax near 'value'.
The break point does not get hit. How can I resolve this?

greendeer
Автор

Getting addicted to watching your videos. Love your voice and how you pay attention to all the little details. Thank you

omniterry
Автор

Inconsistent Accessibility:return type 'List<EmployeeModel>' it seems there is an error in the class privacy in the buisness logic
please help tim ..

christiandiomangay
Автор

More then 2 year ago i had to stop developing and begin learning and maintaining solutions build in ssis, stored procedures using functions, triggers the whole lot.. . Recently I’m starting to develop again. Your videos has help me a lot getting back into development, thank you. You’r for sure one of the better trainers i have found, keep up the good work.

species-xotz
Автор

I'm getting the error 'Object reference not set to an instance of an object.'" @ 11:48.
I have copied everything exactly as in the video. I have also run the source code and still get the same problem. My only difference is that I'm using the latest Visual Studio 16.7, .NET Framework 4.7.2. May the problem may lie there? There are others in the comment section that are having the same problem with no solution.

Thank you

James-zrlu
Автор

these kind of overview videos are very necessary and underrated, I hope you keep implementing them

chiefxtrc