-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Initial checkin for Reverse Engineering #1601
Conversation
… are being looked for in the app project - need to load them from resource.
…moved unneeded services
…very first steps on SQL Server metadata model provider.
… key properties (at the moment just via a non-existent [Key] attribute)
… key properties (at the moment just via a non-existent [Key] attribute)
… the IModel output by the provider and using those annotations to specify the ForeignKey fluent code in OnModelCreating()
…proach. SqlServer Context generation working (not yet EntityType generation).
throw new InvalidProgramException( | ||
"Unable to instantiate type " + type.FullName | ||
+ " in assembly " + providerAssembly.FullName | ||
+ ". Exception message: " + e.Message); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
e.Message
is useless here. It will almost always be "Exception has been thrown by the target of an invocation." It's probably better to not catch here. You could also include the exception as an inner exception.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have changed it so that it no longer catches. But if the error message that comes out is not actionable I think we should change the approach so that the user sees something from the inner exception that can tell them what they did wrong.
Don't block on any of my comments. We can continue the discussion here and resolve them in future PRs and/or design meetings. |
Checked in after updating based on comments above - #86d32d8. |
This is the initial check in for Reverse Engineering on which we'll iterate. See issue #830.
Features include:
Produces DbContext and EntityType POCO classes in current project.
Outputs class, properties and navigations in EntityType classes and class, DbSet's and OnConfiguring() and OnModelCreating() configuration for DbContext class.
Works from command line like Migrations.
Outputs warnings to command line through a Logger.
Code has been pulled out into separate EntityFramework.Relational.Design and EntityFramework.SqlServer.Design projects.
Supports most SQL Server types (see SqlServerTypeMapping for complete list).
Output fluent API for EntityType defines the schema and table name (if necessary) and the primary key.
Output fluent API for properties outputs appropriate fluent API (as necessary) to determine column name and type, including precision and scale; Identity and StoreComputed columns; and MaxLength.
Output fluent API to support 1:N and 1:1 style navigations, plus self-referencing navigations.
Outputs comments in the generated code if it is unable to generate a) EntityType, b) Navigations.
Features still to be worked on:
Converting the CodeGen side to a template approach.
Using EF to load the metadata.
At the moment always produce Key() fluent API. Work on only doing this only when necessary.
Tests. At the moment the tests were running this in a real project and looking at the output. Need unit tests.
DefaultValue for columns.