C# – ASP.NET Core MVC Application with Basic Database Access using Entity Framework – Video

The title somehow looks like random words, picked from a hat at one of those college games we are not supposed to talk about. Anyway, at the second reading it hopefully becomes a bit clearer. And it is simply the “magic” of creating 2 C# classes in visual studio and transferring them to tables in a database with the magic of Entity Framework. Then, with ASP, being able to access the database with the 2 tables and making simple CRUD (Create, Read, Update, Delete) actions. This is how the R in CRUD looks like:

As mentioned, there are 2 main classes in the application – Blog.cs and Post.cs and these have a relation 1-to-many between each other:

 

 

 

 

 

 

 

 

 

 

 

As far as the code is mainly generated from the scaffold features of Visual Studio, I will show only the PostController.cs and the \Posts\Details.cshtml here. The rest is in GitHub and in the video.

PostController.cs

\Posts\Details.cshtml

The video:

The GitHub code:

https://github.com/Vitosh/ASP/tree/master/EFGetStarted

The Original Microsoft.com tutorial:

https://docs.microsoft.com/en-us/ef/core/get-started/aspnetcore/new-db?tabs=visual-studio

Tagged with: , , , ,