ASP .NET Core MVC with EF And C#
Run console application c# .net6 using ctrl+f5
Compile the application using ctrl+shift+b
What is EF (Entity Framework)?
Entity Framework is a new latest technology provided by ODO.net for accessing database.
It is an ORM tool (Object Relation Mapping).
IT provides easy and automated way of mapping between objects(Classes) and Relations (Tables).
It auto generates most of the data-access code.
Why use ORM?
It provides full intellisense support for columns names and table names.(Strongly typed).
What is asp.net core?
Cross Platform, High Performance, Open source framework for building modern, cloud based, internet connected applications.
- 1.Cross platform
- 2.Ability to install the features that are needed for the application
- 3.A complete rewrite of ASP.NET (goal>>cross platform, open source)
- 4.Dependency injection system
- 1.Open Source
- 2.Cross Platform
- 3.Easy integration with client side libraries some of these libraries like react, angular, vue.js
- 4.Lightweight and high performance
- 6.Apis on par with the .NET Framework
Asp.Net Full Framework App
Visual Studio Dependency
Web.Config & XML
No dependency injection by default
Tied to configuration
Not cross platform
ASP.Net Core App
WWW Root folder
No System. Web Dependency
Json, INI & XML (project.xml)
Built in dependency injection
Decoupled From Configuration
- variable is a name given to a storage location in memory, where we can store a value
int Number = 1;
Constant: an immutable value that is a value we cannot change dynamically.
- Constant is used to safety in our application that involves some mathematical calculations.
const float Pi = 3.14f;
- cannot start with a number
- cannot include whitespace, it has to be one word.
- Cannot be a reserved keyword
Use meaningful names:
1)camel case: firstName
2)Pascal Case: FirstName
3)Hungarian notation”strFirstName ->not use in c#
For local variables: camel case: int number;
For Constant: Pascal case: const int MaxZoom = 5;
byte number = 255;
number = number + 1; output -> //0
MVC Architecture separates the three main components
MVC (Model - View - Controller)
Model :- Application Data and behaviour in terms of its problem domain and independent of the UI. Model represents the data, does nothing else. The model is independent of the controller or view.
View :- The HTML markup that we display to the user. View are the components that displays the application’s user interface (UI). Typically this UI is created from the model data.
Controller :- Controllers are the components that handle user interaction (HTTPRequest). Controller works with the model, and ultimately select a view that displays UI Responsible for handling an HTTP request.
MVC architectural pattern
Model -> View -> Controller -> Router
Router :- Select the right controller to handle the request.
Url Pattern In MVC
The url pattern only considered only after domain name part in the URL