Advertisement
otkalce

Entity Framework - scaffold

Mar 28th, 2023
308
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PowerShell 1.00 KB | Source Code | 0 0
  1. # Generate db context and models for local SQL Server database named "Task06", in folder "Models"
  2. dotnet ef dbcontext scaffold "server=.;Database=Task06;Trusted_Connection=True;TrustServerCertificate=True" Microsoft.EntityFrameworkCore.SqlServer -o Models
  3.  
  4. # Generate db context named "Task06CtxNew" and its models (db "Task06", folder "ModelsNew"), and overwrite if it exists
  5. dotnet ef dbcontext scaffold "server=.;Database=Task06;Trusted_Connection=True;TrustServerCertificate=True" Microsoft.EntityFrameworkCore.SqlServer -o ModelsNew --context Task06CtxNew --force
  6.  
  7. # Same as the last command, but use data annotations instead of fluent validation
  8. dotnet ef dbcontext scaffold "server=.\MSSQL2022;Database=Task06;Trusted_Connection=True;TrustServerCertificate=True" Microsoft.EntityFrameworkCore.SqlServer -o ModelsNew --context Task06CtxNew --force --data-annotations
  9.  
  10. # Use following flags to...
  11. # --no-build    ... avoid rebuild
  12. # --verbose     ... get diagnostic messages
  13. # --help        ... print usage info
Tags: ef-cli
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement