Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

Install-Package Microsoft.EntityFrameworkCore.

SqlServer
Install-Package Microsoft.EntityFrameworkCore.Tools

Scaffold-DbContext "Server=(localdb)\
MSSQLLocalDB.;Database=MadZooDigitalDB;Trusted_Connection=True;"
Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models

dotnet add package Microsoft.VisualStudio.Web.CodeGeneration.Design

Get-ChildItem "C:\Projects\Test8\Models" -Filter *.cs | ForEach-Object


{ $scaffoldCmd = 'dotnet-aspnet-codegenerator -p "C:\Projects\Test8\Test8.csproj"
controller -name ' + $_.BaseName + 'Controller -m Test8.Models.' + $_.BaseName + '
-dc MadZooDigitalDbContext -outDir Controllers -namespace Test8.Controllers';
$scaffoldCmd; iex $scaffoldCmd }

// Add services to the container.


builder.Services.AddDbContext<MadZooDigitalDbContext>(options =>

options.UseSqlServer(builder.Configuration.GetConnectionString("DefaultConnection")
));

You might also like