![]() ![]() Visual Studio launches a browser and navigates to where is a randomly chosen port number. In Visual Studio, select Run > Start With Debugging to launch the app. Replace the generated code with the following: In Solution Explorer, in the Controllers folder, add the class TodoController. You create this class by deriving from the class.Īdd a TodoContext class to the Models folder. ![]() The database context is the main class that coordinates Entity Framework functionality for a given data model. The database generates the Id when a TodoItem is created. Name the class TodoItem, and then click New. Right-click the Models folder, and select Add > New File > General > Empty Class. You can put model classes anywhere in your project, but the Models folder is used by convention. ![]() In Solution Explorer, right-click the project. In this case, the only model is a to-do item. Select, and then select Add Package.Ī model is an object representing the data in your app. Alternatively, you can right-click Dependencies, and then select Add Packages.Įnter EntityFrameworkCore.InMemory in the search box.This database provider allows Entity Framework Core to be used with an in-memory database.įrom the Project menu, select Add NuGet Packages. Install the Entity Framework Core InMemory database provider. Change the URL to The ValuesController data is displayed: Visual Studio launches a browser and navigates to You get an HTTP 404 (Not Found) error. NET Core App > ASP.NET Core Web API > Next.Įnter TodoApi for the Project Name, and then click Create. Prerequisitesįrom Visual Studio, select File > New Solution. See Introduction to ASP.NET Core MVC on macOS or Linux for an example that uses a persistent database. macOS, Linux, Windows: Web API with Visual Studio Code. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |