Asp.Net Core reverse engineering

                                                  Reverse engineering
1. Reverse engineering is the entity type and a class based on the process frame group DbContext class database schema
2.Scaffold-DbContext (context database scaffolding)
    using Scaffold-DbContext (context database scaffold) command generation models and context
2 scaffolding:
    compiler (scaffold) corresponding code according to the rules established crop programmer, operation of the database (the CRUD)
3. syntax:
    the scaffold-the DbContext [-connection] <String> [-provider] <String> [-outputdir <String >] [-Context <String>]
[-Schemas <String>] [-tables <String>] [-DataAnnotations] [-Force] [-Project <String>]
[-StartupProject <String>] [-Environment <String >] [<CommonParameters>]
4. parameters:
    [-connection] <string>: database connection string, the connection string to read this database schema.
    [-Provider] <String>: The second parameter is the name of the provider. Provider name is generally a package name NuGet same provider, for example: Pomelo.EntityFrameworkCore.MySql, Microsoft.EntityFrameworkCore.
    [-OutputDir <String>]: Entity class files stored in directory
    [-Context <String>]: Create a separate directory to the type of the entity from the class of the base frame DbContext class.
    [-Schemas <String>]: for each table in the schema
    [-Tables <String>]: specify a table, for example: the DbContext ... -tables the Scaffold-Artist, Album
    [-DataAnnotations]: Reserved Name the original name of the database will remain ineffective repair synthesis and .NET identifier names, navigation attributes will follow the naming conventions .NET
    [-Force]: update model
    [-Project <String>]: has built base frame DbContext class name as the name suffix database default context. To specify a different use -Context
    [-StartupProject <String>]: I want to use to start the project. If omitted, the solution is to start the project using
    [-Environment <String>]
    [<CommonParameters>]
5. works
    read at the beginning of the database schema reverse engineering. It reads information about tables, columns, constraints, and indexes.
    Next, it uses the information architecture to create EF Core models. Tables are used to create the entity type; use the column to create a property; And foreign keys are used to create relationships.
    Finally, the model is used to generate code. Corresponding entity type class, Fluent API and data annotation has been built base frame to recreate the same model from your application.
6. invalidity
    information inheritance hierarchy inherent related to the type and the table split the database schema does not exist in
    some column types may not be supported by the provider EF Core
    tables without primary keys are currently not reverse engineer.
7. The mounting assembly
--MySQL Version:
    MySql.Data.EntityFrameworkCore
    Pomelo.EntityFrameworkCore.MySql
    Microsoft.EntityFrameworkCore.Tools
    Microsoft.VisualStudio.Web.CodeGeneration.Design
--SQLService Version:
    Microsoft.EntityFrameworkCore
    Microsoft.EntityFrameworkCore.SqlServer
    Microsoft.EntityFrameworkCore .Tools
    Microsoft.VisualStudio.Web.CodeGeneration.Design
8. the following statement generation program entity classes bag Manager console
--MySQL version:
  generating the first entity classes:
    Scaffold-DbContext "Server=127.0.0.1;port=3306;Database=db; User=root;Password=root;" Pomelo.EntityFrameworkCore.MySql -OutputDir Models
  更新实体类:
    Scaffold-DbContext "Server=127.0.0.1;port=3306;Database=db; User=root;Password=root;" Pomelo.EntityFrameworkCore.MySql -OutputDir Models -Force

--SQLService Version:
  generating the first entity:
    the Scaffold-the DbContext "Server = 127.0.0.1; Port = 3306; Database = DB; the User = the root; Password = the root;" Models Microsoft.EntityFrameworkCore.SqlServer -outputdir
  update entity classes:
    Scaffold-DbContext "Server = 127.0.0.1; port = 3306; Database = db; User = root; Password = root;" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models -Force

Guess you like

Origin www.cnblogs.com/qidakang/p/11302327.html