-
Notifications
You must be signed in to change notification settings - Fork 227
Full control over the generated code
Simon Hughes edited this page Nov 13, 2024
·
20 revisions
You can specify the following:
- Filter tables, columns, views, stored procedures, table-valued functions and scalar-valued functions to just the minimum set you require. This is key to having a fast EntityFramework.
- Generate FakeDbContext for easy unit testing.
- Rename tables, columns and stored procedures in your DB context.
- Generate separate files or a single file.
- Generator type: Ef6 and EfCore, including your own custom variation.
- Create enumerations from database tables.
- Which database you are reverse engineering: SQL Server, PostgreSQL, SQL CE 4 or SQLite.
- Which name to give your DbContext class & interface.
- What namespace you would like to use.
- Supports multiple result sets from stored procedures.
- Supports cross-database synonym tables.
- Control if the schema name is prepended to the table name. This stops name conflicts if the same table name is used in different schemas
- Ability to perform table renaming. Such as removing a prefix or certain characters from all the tables. Such as tblOrders to Orders, Shipments_AB to Shipments, etc.
- Supports English Pluralisation and the ability to provide your own custom Pluralisation service.
- Includes support for custom pluralisation dictionaries to override singular/pluralisation of words that are not supported by the main pluralisation service.
- Which
{{mustache}}
templates to use: Ef6, EfCore2, EfCore3, EfCore5, EfCore6, or your own FileBased templates. - Ability to control exactly what is generated. Such as POCO classes, DbContext, DbContext interface, POCO Configuration/Mapping classes, Stored procedures and Enums. This is required for enterprise software where different parts of the configuration can exist in different folders or projects.
- Ability to control usage of mapping tables.
- Which connection string to use for the generator.
- Which connection string name to use from your app.config/web.config/appsettings.json.
- Additional base interfaces for your DB context interface. E.g. IDisposable
- Which base classes for the DB context. E.g. for ASP.NET Identity use
IdentityDbContext<ApplicationUser>
- Ability to add a default (parameter-less) constructor to your DbContext.
- Customize the name of the configuration classes. "Configuration", "Mapping", "Map", etc. This is appended to the POCO class name to configure the mappings.
- Ability to make classes partial.
- Optionally use PascalCase. This will rename the tables & fields to use PascalCase. If not, then table & field names will be left alone.
- Ability to use C# 6 property initialisers to set defaults.
- Ability to mark all navigation properties as virtual or not, to support or disable EF Lazy Loading feature.
- Optionally include comments. This will add the non-PascalCased names of fields, primary keys and foreign keys as comments.
- Optionally include extended properties as comments. You can also specify if they should appear in a summary block above the field, or at the end of the field. An extended property is the description field in a SQL Server database.
- Optionally include comments describing connection settings used to generate the files.
- Optionally include field name constants in your POCO's that match your properties. #741
- Ability to disable geography types. This turns off DbGeography and DbGeometry as OData doesn't support entities with geometry/geography types.
- What collection type to use for navigation properties.
List
(default),ObservableCollection
for example. - What nullable shorthand to use.
T?
orNullable<T>
- Ability to specify a default IDbContextFactory implementation for easy dependency injection.
- Ability to include the flag "OPTION (QUERYTRACEON 9481)" for use with SQL Server 2014 (SQL Server 2014 had a faulty query plan optimisation).
- Control the use of the [GeneratedCode] attribute.
- Control the use of private setters for computed columns.
- Ability to specify additional namespaces to include in the generated code.
- Ability to suppress placing the generated code in a #region.
- Ability to suppress the writing of a namespace.
- Ability to suppress the writing of #pragma.