Dotnet Core - Avinashlikes/Wiki GitHub Wiki

Dotnet core make working in MAC :

export PATH=/usr/local/share/dotnet:$PATH

  1. .Net Core SDK

  2. VS COde

  3. VS Code Extension

  4. Npm install -g yo generator-aspnetcore-spa

  5. SQL Server

  6. On windows- SQL Express

  7. MACOS /Linux : Docker Image

  8. Check where docker is running on your Mac machine

  9. Sudo docker pull microsoft/mssql-server-linux

  10. $ sudo docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=AndharwaraPassword!@#' -p 1433:1433 microsoft/mssql-server-linux

  11. For management server in linux: bit.ly/sqlservertools

  12. For Mac : macsqlclient.com

  13. How to check any error occurred in docker image

  14. First find the docker container by running: $ docker ps -a

  15. The dump that error log into local folder by running: $ docker cp :/var/opt/mssql/log/errorlog

  16. E.g: sudo docker cp b35f:/var/opt/mssql/log/errorlog .

  17. Then you will fin error log file into local path.

  18. Generate project using woman

  19. First create a folder called Vega

  20. Go to that folder $ cd

  21. Run yo command: $ yo aspnetcore-spa

  22. Select the appropriate type of project you want to create

  23. Open VSCODE from command line

  24. Open vs code -> shift+ command+p

  25. Search - > command

  26. Then install Shell command 'code' in PATH.

  27. After choosing it you will get : Shell command 'code' successfully installed in PATH.

  28. It is done. You may run $ code .

  29. To open from command prompt.

  30. Set Enviromnemtn variable to development in Mac

  31. Edit bash_profile

  32. Vm .bash_profile

  33. Export ASPNETCORE_ENVIRONMENT=Development

Dotnet Watch

  1. Add dotnet watch to use it as node mon
  2. And then dotnet restore
  3. Run $dotnet watch run

Debuging in VSCODE

  1. shift+command + D

  2. 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

⚠️ **GitHub.com Fallback** ⚠️