[.NET Core] - Create DbContext using EF Core's Scaffold-DbContext scaffolding command

Scaffold-DbContext Command

parameter

Scaffold-DbContext [-Connection] <String> [-Provider] <String>
[-OutputDirectory <String>] [-ContextClassName <String>]
[-Tables <String>] [-DataAnnotations] [-Project <String>]
[<CommonParameters>]

Example (note that the backslash is one)

Scaffold-DbContext "Server=.\TestDB;Database=TestDbName;Trusted_Connection=True;MultipleActiveResultSets=true;" Microsoft.EntityFrameworkCore.SqlServer -OutputDir DataModel1
Scaffold-DbContext "Server=.\TestDB;Database=TestDbName;User ID=sa;Password=sa;" Microsoft.EntityFrameworkCore.SqlServer -OutputDir DataModel2

Effects (reproduced from References)

 

 References

Getting started with EF Core on ASP.NET Core with an existing database
https://docs.microsoft.com/en-us/ef/core/get-started/aspnetcore/existing-db

Entity Framework Core of .NET Core How do you create DbContext
http://www.cnblogs.com/tdws/p/5874212.html

.net core 使用 ef core
http://www.cnblogs.com/ziye/p/7562889.html

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324608877&siteId=291194637