-
-
Notifications
You must be signed in to change notification settings - Fork 301
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
Is the Reverse engineering tool generally intended to be used once? #365
Comments
You can choose to only generate Entities, and then only some - would that work for you? (They would of course need to be part of your DbContext already) - I use the feature continously. But I do not use (or worse modify) DataAnnotations. |
NTW, there is a discussion about Required annotation here, that you may find relevant: #348 - you sound like you have yet another take on it (AllowEmptyStrings = true) |
Hi Erik, Ah, I had forgot that option was there, on the last screen "what to generate", with the options: My typical workflow - involves making a few table changes, then running the tool again, selecting all the tables I need in my model. With the option "DbContext and Entities" picked, only those tables selected will be in the model. So If I was to choose "Entities only", will any entities already generated be preserved and not deleted? Regarding your 2nd comment above, yes, this is related and the same issue that I am having with the emptystrings/required attributes, and I had read through that and its related threads both here and over on the EF github regarding scaffolding and default constraints etc. The whole issue came up because there are a few tables that contain a limited number of varchar fields are marked not null but the requirements are that a record allow empty strings. So I modified the attributes on those entites, but those changes will get blown away when the model/dbcontext is regenerated. This might not happen for weeks or months later when that particular table/entity is regenerated and I had not made a note of making the custom changes. So in short, there are two things I am trying to address: |
@ErikEJ just to update, I can confirm the "entities only" option, just tried that and will alleviate alot of the problems I was running into having custom attributes getting overwritten. That works! Just updated a table and did the rev eng step with only that entity selected and only that entity was regenerated, while leaving the others unchanged. On the other front, I think one solution mention in another post was to handle this non-null empty string issue was to somehow generate the AllowEmptyStrings = true when there is a default constraint applied. The threads I read on that is that is not so simple and might involve the EF Core team updating the scaffolding features? Either way, that would be great but at least for now, I can work around it now that I have a way to rework schema changes back into my model for a limited number of entities WITHOUT blowing away other entities. |
Have a look at this: #412 (comment) |
My typical workflow will typically involve adding/updating a few tables, then Reverse eng with the tool to update my model. There are close to 100 tables in the Db, with a handful of them I have added custom attributes on the Data annotations, eg.
[Required] to [Required(AllowEmptyStrings = true)]
This is to get around the issue of having non-null varchar field but allow empty strings on a few selected fields.
If I simply follow the Reverse eng path, I need to select the tables to be generated, which is used to recreate the entire db model/context. I get that, but I suppose what Im wondering is if there is a way to reverse eng only a handful of tables (to reflect the schema changes in the Db for those tables), rather than all or nothing. If I do the latter, then I loose those custom annotations that were added earlier to tables that are not part of the current set of changes Im working on, and they must be added back manually. Granted its only a handful, but it gets me out of the UI workflow.
Hope that helps.
Another suggestion possibly, is to allow custom generation of a handful of entities, where I could specify those custom annotation attributes?
So I guess my question is this: Is the reverse engineering tool option, generally used once eg. when creating a new project?
Thanks again, and love the tool!
The text was updated successfully, but these errors were encountered: