Skip to main content

Utils Commands - .NET

dotnet new webapi

# Minimal version
dotnet new web

dotnet new list

dotnet new gitignore

# nuget.org // .NET Gallery
dotnet add package Microsoft.EntityFrameworkCore.InMemory --version 6.0.3

# Razor
dotnet new webapp

dotnet new page --name Pizza --namespace RazorPagesPizza.Pages --output Pages

# --- EF (Entity Framework) Core Migrations -----------------

# Install globally
dotnet tool install -g dotnet-ef

# Update 
dotnet tool update -g dotnet-ef

# Generate EF Core migrations
dotnet ef migrations add InitialCreate

# Execute EF Core migrations
dotnet ef database update

#----------- Udemy E-commerce course ------------
# create new solution file
dotnet new sln

# create webapi in API directory
dotnet new webapi -o API

# add API into the solution file
dotnet sln add API

# run the app
dotnet run

# update dotnet-ef (migration tool)
dotnet tool update --global dotnet-ef

# generate migrations in a specific folder
dotnet ef migrations add InitialCreate -o Data/Migrations

dotnet ef database update

dotnet ef database drop

dotnet watch run
dotnet watch
dotnet watch --no-hot-reload

# Add migration
dotnet ef migrations add BasketEntityAdded

# Secrets manager
# https://learn.microsoft.com/en-us/aspnet/core/security/app-secrets?view=aspnetcore-7.0&tabs=windows
dotnet user-secrets init
dotnet user-secrets set "Movies:ServiceApiKey" "12345"
dotnet user-secrets list