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 databases.
It is an ORM tool (Object Relation Mapping).
It provides an 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 column 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-platformASP.Net | 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 for safety in our application that involves some mathematical calculations.
Ex:
const float Pi = 3.14f;
#Identifiers:
- cannot start with a number
Ex:
one route
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 behavior in terms of its problem domain and independent of the UI. The model represents the data and does nothing else. The model is independent of the controller or view.
View:- The HTML markup that we display to the user. The view is the component 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). The controller works with the model and ultimately selects 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 the 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.