Reverse engineers an existing database and generates EntityFramework Code First POCO classes, DbContext and Configuration mappings. Works for
SQL Server and SQL Server Compact 4.0
This has now been made into a visual studio extension. See documentation tab for further details.
Head over to here to watch a video on how it works.
Highly customisable output
This generator was designed to be customisable from the very beginning, and not fixed and rigid like other generators.
To make a donation, please click here.
Full control over the generated code
- Specify additional base interfaces for your DB context interface. E.g. IDisposable
- Specify the base classes for the DB context. E.g. for ASP.NET Identity use IdentityDbContext<ApplicationUser>
- Specify which connection string to use. The generator will search your whole solution for it.
- Specify a list of config files for the connection string to be searched for. The config files are searched for in the local project first, then the whole solution second.
- 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.
- Generate separate files, or as a single file.
- Optionally use CamelCase. This will rename the tables & fields to use CamelCase. If not, then table & field names will be left alone.
- Optionally include comments. This will add the non CamelCased 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 database Views.
- Ability to disable geography types. This turns off use of System.Data.Entity.Spatial.DbGeography and System.Data.Entity.Spatial.DbGeometry as OData doesn't support entities with geometry/geography types.
- Specify what the collection type for navigation properties. “List” (default), "ObservableCollection" for example.
- Ability to specify what the namespace is for your custom collection type.
- Specify if you’d like FakeDbContext and FakeDbSet classes adding for easy unit testing.
- Ability to include the flag “OPTION (QUERYTRACEON 9481)” for use with SQL Server 2014.
- Ability to specify additional namespaces to include in the generated code.
- Ability to specify a list of custom DB context interface functions. Set MakeClassesPartial=true, and implement your partial DbContext class functions.
- Supports Migrations.
- Supports Stored Procedures.
- Supports Table Valued Functions.
- Supports Pluralisation services such as English and Spanish, etc.
- Includes support for custom pluralisation dictionaries to override singular/pluralisation of words that are not support by the main pluralisation service.
- Ability to control exactly what is generated. Such as POCO classes, DB Context, Unit of work (DB Context interface), POCO Configuration/Mapping classes, Stored procedures. This is required for enterprise software where different parts of the configuration
can exist in different folders or projects.
- 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 filtering tables and stored procedures to just the minimum set you require. This is key to having a fast EntityFramework.
- 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.
- Ability to perform column renaming.
- Ability to perform stored procedure renaming.
- Ability to generate WCF contracts. This is only intended as a helper, to get you started creating WCF contracts, and to save a lot of typing.
- The generator uses callbacks when generating code. This allows you to control writing the following:
- Poco class attributes.
- Poco base classes.
- Poco base class body.
- Poco column / field.
- Stored procedure function name, function parameters and @parameters.
- Stored procedure - declaration of the SqlParameters, anonymous array and setting of the SqlParameters.
- Stored procedure - Setting the name of the return model from a stored procedure, and controlling the field names used in the return model.
A UI for the generator is available at
https://efreversepocoui.codeplex.com See the downloads tab.