scafolding tables into model.

should install 4 packages

install-package microsoft.entitiyframeworkcore -version 5.0

install-package microsoft.entitiyframeworkcore.design -version 5.0

install-package microsoft.entitiyframeworkcore.sqlserver -version 5.0

install-package microsoft.entitiyframeworkcore.tools-version 5.0

install-package swashbuckle.aspnetcore -version 5.0.3


Scaffold-DbContext "SERVER=10.0.60.74;Initial Catalog=TestDB;User ID=sa;Password=Nepal@123;TrustServerCertificate=True;" microsoft.entityframeworkcore.sqlserver -OutputDir Models


PM> scaffold-DbContext "SERVER=DESKTOP-JENHTHC;initial CATALOG=aspnet-WebApplication-41EC092B-9D08-4320-9980-F1F763F2A144;USER=sa;PASSWORD=SOFTWARE;TRUSTED_CONNECTION=TRUE;" microsoft.entityframeworkcore.sqlserver -OutputDir Models


note the dbcontext will also be available in model directory. 


if forcefull is needed 

 scaffold-DbContext "SERVER=ITG;initial CATALOG=Compliance;USER=sa;PASSWORD=ccbl_software@2021;" microsoft.entityframeworkcore.sqlserver -OutputDir Models -force



only one table , many tables with comma


scaffold-DbContext "SERVER=INTDBSRV;initial CATALOG=PumoriNotification;USER=sa;PASSWORD=software;" microsoft.entityframeworkcore.sqlserver -OutputDir Models -Tables TrainingNeedAssessment -f


Create or Generate Model from Existing Database in Entity Framework Core - YouTube

Comments