-
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
Reverse engineer model from database #830
Comments
Moved comment from #2465. From @ErikEJ: Is this a good time to start investigating using Reverse Engineering with SQLCE, or is it too early? From @divega: @ErikEJ I personally believe it is a good time for you to get started with it. If you hit issues or have any feedback we can make adjustments. From ErikEJ: @divega Sounds great, is there some docs/design specs? Or a drawing? 😄 I have a few questions: |
A) On IDatabaseMetadataModelProvider, GenerateMetadataModel(string connectionString) generates an IModel containing EntityTypes. DbContextTemplate() and EntityTypeTemplate() return the relevant templates as strings (you get to look them up however you want - however note #2418 where we'll be providing a way for customers to override the default templates). B) First the DbContextTemplate template is executed being passed an instance of DbContextGeneratorModel. On DbContextGeneratorModel you'll find a property MetadataModel - which is the model you generated in step A) above. C) Then we loop over all EntityTypes in the MetadataModel and on each one execute the EntityTypeTemplate passing in an EntityTypeGeneratorModel. Note that on EntityTypeGeneratorModel you'll find a property EntityType which is the EntityType being processed (and which can refer to its parent - the metadata model - if needed). D) Each Model passed in also has a Helper property - which is an instance of DbContextCodeGeneratorHelper or EntityTypeCodeGeneratorHelper respectively. These contain helpful methods for ordering the entities, setting up configuration for the DbContext based on the model etc. Feel free to inherit from these classes and override methods or provide new ones as you see fit (but bear in mind #2465). |
I think we need to quickly discuss how we want the "provider invariant name" to work in EF7. My vote is that we just use the assembly/package name, but we should discuss this. |
@lajones Thanks, that should be enough to get me going, will also await your "unblocking" of the hardcoded provider name. a: As a developer, I want to reverse engineeer my existing SQL CE database to use it with EF7. Is that just about correct? |
@lajones @divega @rowanmiller Rev Eng now works for the SQLCE provider! Thanks for your timely support 😄 |
Sweet 🎉 |
@ErikEJ not sure if I have said this before but... you rock! 😄 |
@ErikEJ You're v welcome. Thanks for all your hard work! |
@lajones And the E2E tests revealed a couple of small bugs in my SQL CE scripting engine: https://sqlcetoolbox.codeplex.com/SourceControl/changeset/96873 - thanks! |
@ErikEJ - Glad to help! |
Closing this over-arching issue for the whole of RevEng. Now we'll track each individual bug/feature as it comes up. Raised issue #2751 to track ability to select tables. |
How do you specify the output path for ef scaffold reverse engineering? |
A lot has changed since the above comments. If you do |
I am running CLR-x64-1.0.0-beta7-15532 and -o is not an option |
And i'm running CLR-x64-1.0.0-beta7-15540 and -o is not an option too. |
You need to run a beta 8 daily build for that feature to work. And you need to customize the templates in order to force the tooling to use DataAnnotations (I am working on a blog post) |
@claysmith - that's correct - the |
@lajones thanks for the heads up! How do you switch between attribute and fluent then? |
Sorry for an old question: when do you think to develop the reverse engineering of Views? |
You mean "trick" reverse engineering? No I'm afraid not. Each provider retrieves the corresponding metadata in their own On the other hand it's not likely to be complicated to add it. We have an existing issue for this: #1679. It's been on the Backlog for a while - perhaps it's time to revisit it? |
FYI everyone, I've just published the Npgsql reverse engineering provider. I've confirmed that the EF7 database-first tutorial works just fine with it. |
Congrats! |
Yep congrats! Really cool! |
Looks like we didn't have a work item tracking this. We need tooling to reverse engineer a model from a database. For the initial cut this should include the functionality from EF6.x (ability to select tables etc.).
This does not include the ability to incrementally update the model based on changes to the database, #831 tracks that.
The text was updated successfully, but these errors were encountered: