Dotnet Core - Avinashlikes/Wiki GitHub Wiki
Dotnet core make working in MAC :
export PATH=/usr/local/share/dotnet:$PATH
-
.Net Core SDK
-
VS COde
-
VS Code Extension
-
Npm install -g yo generator-aspnetcore-spa
-
SQL Server
-
On windows- SQL Express
-
MACOS /Linux : Docker Image
-
Check where docker is running on your Mac machine
-
Sudo docker pull microsoft/mssql-server-linux
-
$ sudo docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=AndharwaraPassword!@#' -p 1433:1433 microsoft/mssql-server-linux
-
For management server in linux: bit.ly/sqlservertools
-
For Mac : macsqlclient.com
-
How to check any error occurred in docker image
-
First find the docker container by running: $ docker ps -a
-
The dump that error log into local folder by running: $ docker cp :/var/opt/mssql/log/errorlog
-
E.g: sudo docker cp b35f:/var/opt/mssql/log/errorlog .
-
Then you will fin error log file into local path.
-
Generate project using woman
-
First create a folder called Vega
-
Go to that folder $ cd
-
Run yo command: $ yo aspnetcore-spa
-
Select the appropriate type of project you want to create
-
Open VSCODE from command line
-
Open vs code -> shift+ command+p
-
Search - > command
-
Then install Shell command 'code' in PATH.
-
After choosing it you will get : Shell command 'code' successfully installed in PATH.
-
It is done. You may run $ code .
-
To open from command prompt.
-
Set Enviromnemtn variable to development in Mac
-
Edit bash_profile
-
Vm .bash_profile
-
Export ASPNETCORE_ENVIRONMENT=Development
Dotnet Watch
- Add dotnet watch to use it as node mon
- And then dotnet restore
- Run $dotnet watch run
Debuging in VSCODE
-
shift+command + D
-
For EF : dotnet add package Microsoft.EntityFrameworkCore.SqlServer 2. The correct format to add a new migration is $ dotnet ef migrations add yourMigrationName and to update database is $ dotnet ef database update
Connection String for DB:
1. "ConnectionStrings": {
"DefaultConnection": "Data Source=127.0.0.1,1433;Initial Catalog=School;User ID=sa;Password=William22!;" }
Add : this to startup in coifguration:
services.AddDbContext(options => { options.UseSqlServer(Configuration.GetConnectionString("DevConnection"));
});
Adding Controller :
Run the following commands:
dotnet tool install -g dotnet-aspnet-codegenerator dotnet add package Microsoft.VisualStudio.Web.CodeGeneration.Design dotnet restore dotnet aspnet-codegenerator controller -name BlogsController -m Blog -dc BloggingContext --relativeFolderPath Controllers --useDefaultLayout --referenceScriptLibraries The tool install and add package commands install the tooling that can scaffold controllers and views. The restore command ensures that all of the project's packages are downloaded, and the aspnet-codegenerator command does the scaffolding.
Bencode 1003108
OPXS075
OPXS010
dotnet new webapi -o TodoApi dotnet sln todo.sln add todo-app/todo-app.csproj back-end/back-end.csproj dotnet build dotnet run dotnet test ~/projects/test1/test1.csproj dotnet publish