Skip to content

EsraaAlsharit/C_sharp

Repository files navigation

C_sharp

Installing the .NET 6 SDK

https://dotnet.microsoft.com/en-us/download/dotnet/6.0

dotnet --version

Installing Tools: dotnet-ef

run it once to make it global it is for Entity Framework Core Entity Framework and Connecting to MySQL

dotnet tool install --global dotnet-ef

dotnet tool install --global dotnet-ef --version 8.\*

Installing the "C# for Visual Studio Code" plugin from OmniSharp

Starting up a new Console App

mkdir FirstCSharp
cd FirstCSharp
dotnet new console

One line (-o creates the folder for you if the folder name does not already exist):

dotnet new console -o FirstCSharp

run

dotnet run

Program.cs File in Older Versions of .NET

using System;

namespace FirstCSharp
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello, World!");
}
}
}

Intro to ASP.NET Core

blid web project

dotnet new web --no-https -o ProjectName

run

dotnet run
dotnet watch run

bulid mvc project

dotnet new mvc --no-https -o ProjectName

everything is up to date

dotnet restore

Head into your project and run these two commands from the terminal:

will be in ProjectName.csproj file

dotnet add package Pomelo.EntityFrameworkCore.MySql --version 6.0.1
dotnet add package Microsoft.EntityFrameworkCore.Design --version 6.0.3

make migrations

needed just ones for connected to DB

dotnet ef migrations add FirstMigration

or

dotnet ef migrations add FirstMigration -v

to remove the migration

dotnet ef migrations remove

push the changes for the database to sql

it can be reuse for the code

dotnet ef database update

dotnew have many templete as

  • dotnet new console
  • dotnet new web
  • dotnet new mvc
  • dotnet new webapp
  • dotnet new webapi
  • ...

Another key difference between ASP.NET and .NET is the programming language used for development. While ASP.NET is developed using C#, .NET is developed using multiple languages, such as C#, Visual Basic, and F#. This makes .NET more versatile and allows developers to choose a language that works best for their project.