A few highlights are as follows.
Thursday, February 6, 2020
Web API Core Startup.cs page
This is one of an important class that introduces core changes to the web API terminology in .net core.
A few highlights are as follows.
A few highlights are as follows.
Labels:
.net,
.net core,
asp.net,
asp.net core,
c#,
configuration,
we api,
web api core
How to create a Web API Core and Entity Framework Core Project in Visual Studio Code
Install .NET Core
Use one of the methods below to create a web api project
Run the following command to create a web api project from a template from the command prompt
In visual studio code, Go to Terminal
Add following packages using the commands in the terminal or command prompt, command palet
dotnet add package Microsoft.EntityFrameworkCore.Sqlite
Create your DbContext class and Model classes
Use the following commands to create the database.
Use one of the methods below to create a web api project
Run the following command to create a web api project from a template from the command prompt
- Go to the project location using cd <path>
- CD C:\Users\david\Documents\\Projects\mot_service
- Then run following command
- dotnet new webapi -o theprojectname -f netcoreapp3.1
- cd theprojectname
- Then run following command that will open the project in Visual Studio Code
- code -r ../theprojectname
In visual studio code, Go to Terminal
- dotnet new webapi -o theprojectname -f netcoreapp3.1
- Open the project from the editor or run in the terminal :
- code -r ../theprojectname
dotnet add package Microsoft.EntityFrameworkCore.Sqlite
Create your DbContext class and Model classes
Use the following commands to create the database.
- To add migrations - dotnet ef migrations add InitialCreate
- To create database - dotnet ef database update
To see the sqllite file use SQL Lite Studio or sqlitebrowser
Wednesday, February 5, 2020
Entity Framework Core Visual Studio Code : Error when adding migrations
Error
Could not execute because the specified command or file was not found.
Possible reasons for this include:
* You misspelled a built-in dotnet command.
* You intended to execute a .NET Core program, but dotnet-ef does not exist.
* You intended to run a global tool, but a dotnet-prefixed executable with this name could not be found on the PATH.
Solution:
Make sure .NET Core is installed and added to environment variable path.
https://docs.microsoft.com/en-us/dotnet/core/tools/troubleshoot-usage-issues
Subscribe to:
Posts (Atom)