工具的scaffold-dbcontext(数据库上下文脚手架)指令来生成models和context。
指令详细介绍:
Scaffold-DbContext [-Connection]
[-Schemas
[-StartupProject
PARAMETERS
-Connection
Specifies the connection string of the database.
-Provider
Specifies the provider to use. For example, Microsoft.EntityFrameworkCore.SqlServer.
-OutputDir
Specifies the directory to use to output the classes. If omitted, the top-level project directory is used.
-Context
Specifies the name of the generated DbContext class.
-Schemas
Specifies the schemas for which to generate classes.
-Tables
Specifies the tables for which to generate classes.
-DataAnnotations [
Use DataAnnotation attributes to configure the model where possible. If omitted, the output code will use only the fluent API.
-Force [
Force scaffolding to overwrite existing files. Otherwise, the code will only proceed if no output files would be overwritten.
-Project
Specifies the project to use. If omitted, the default project is used.
-StartupProject
Specifies the startup project to use. If omitted, the solution's startup project is used.
-Environment
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账户认证的意思)