ASP .NET Core MVC with EF And C#
Reference Website
https://www.tutorialsteacher.com/
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
Advantages:
- 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
- 5.Cloud-ready
- 6.Apis on par with the .NET Framework
App Difference:
Asp.Net Full Framework App Root Folder Visual Studio Dependency System.Web Web.Config & XML No dependency injection by default Tied to configuration IIS 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 Cross Platform |
- variable is a name given to a storage location in memory, where we can store a value
Ex:
int number;
int Number = 1;
- Constant is used to safety in our application that involves some mathematical calculations.
Ex:
const float Pi = 3.14f;
#Identifiers:
- cannot start with a number
Ex:
oneRoute
1route*
- cannot include whitespace, it has to be one word.
firstName
first name*
- Cannot be a reserved keyword
@int
int*
Use meaningful names:
firstName
Naming Conventions:
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;
Primitive types:
1)integral numbers
byte
short
int
long
2)real numbers
float
decimal
double
3)character
char
4)boolean
bool
overflowing:
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
Ex: localhost:1234/{Controller}/{action}/{id}
localhost:1234/Book/Index/2
0 Replies to “ASP .NET Core MVC With EF And C#”
Leave a Reply
Your email address will not be published.