Forum Discussion

Lesego13's avatar
Lesego13
Copper Contributor
Nov 17, 2022

Connect the API to the data source

How do you Scaffold the database into the project (connect the project to the database)?

  • Kgopolang's avatar
    Kgopolang
    Copper Contributor
    Hey Type in the the Package Manager Console: dotnet ef dbcontext scaffold "<>" Microsoft.EntityFrameworkCore.SqlServer -o Models And replace <> with your connection string. If the following error occurs do the following: Your startup project 'MyTest Demo' doesn't reference Microsoft.EntityFrameworkCore.Design. This package is required for the Entity Framework Core Tools to work. Ensure your startup project is correct, install the package, and try again. Click on the solution to see the .csproj file Add the following line <GenerateRuntimeConfigurationFiles>True</GenerateRuntimeConfigurationFiles> If it still happens, open your startup.cs and add the following if it not there using Microsoft.EntityFrameworkCore;

Resources