scaffold-dbcontext 命令的使用


工具的scaffold-dbcontext(数据库上下文脚手架)指令来生成models和context。

指令详细介绍:

Scaffold-DbContext [-Connection] <String> [-Provider] <String> [-OutputDir <String>] [-Context <String>]
[-Schemas <String>] [-Tables <String>] [-DataAnnotations] [-Force] [-Project <String>]
[-StartupProject <String>] [-Environment <String>] [<CommonParameters>]

PARAMETERS
-Connection <String>
Specifies the connection string of the database.

-Provider <String>
Specifies the provider to use. For example, Microsoft.EntityFrameworkCore.SqlServer.

-OutputDir <String>
Specifies the directory to use to output the classes. If omitted, the top-level project directory is used.

-Context <String>
Specifies the name of the generated DbContext class.

-Schemas <String>
Specifies the schemas for which to generate classes.

-Tables <String>
Specifies the tables for which to generate classes.

-DataAnnotations [<SwitchParameter>]
Use DataAnnotation attributes to configure the model where possible. If omitted, the output code will use only the fluent API.

-Force [<SwitchParameter>]
Force scaffolding to overwrite existing files. Otherwise, the code will only proceed if no output files would be overwritten.

-Project <String>
Specifies the project to use. If omitted, the default project is used.

-StartupProject <String>
Specifies the startup project to use. If omitted, the solution's startup project is used.

-Environment <String>
Specifies the environment to use. If omitted, "Development" is used.

 

 

示例:

Scaffold-DbContext "Server=.\;Database=MvcMovie;Trusted_Connection=True;" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models -Force

Integrated Security(是否集成认证 windows账户认证的意思)


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM