1 year ago

#151927

test-img

Florent

EF Core - Scaffold Database

I have a ASP.NET Core Web Api Project and a class library project inside a solution. I want to use the database first approach. The generated models and context should be generated inside the class library project in a folder called Models. This is the command that I am using:

Scaffold-DbContext "Server=localhost;Database=AntragDB;Trusted_Connection=True;" Microsoft.EntityFrameworkCore.SqlServer -Namespace "DbLibrary.Models" -OutputDir "C:\Users\test\source\repos\DigVPapi\DbLibrary\Models" -force

For some reason the models get generated inside the root folder of the web api project which is unexpected. Here is what it looks like:

enter image description here

Now all those classes that you see on the bottom like Adresse and so on get created when the scaffold is done. But at the same time its updating my model classes inside my DbLibrary Project correctly. What am I doing wrong and why does it do that? I have to say that I did use the scaffold command before for the web api where I specified a models folder inside the web api project.

asp.net-core

entity-framework-core

.net-5

asp.net-core-scaffolding

0 Answers

Your Answer

Accepted video resources