Multi time generate code issue

Hi,

I am facing one issue on multi time generate code.

For example, first time, I generate code on one table, and secod time generate code on another table, it seems whatever option on 'override the existing file' does not works.

  1. if override the existing file, the exist service file in services folder will be overrided, then the first time generated code does not works anymore.
  2. if does not override the existing file, the second time generated codes will not works.

Anything I was not in the right way?
Thanks.
Jeffers

Hi @Jeffers,

You should pick all tables you want to generate code for every time. If you don't check overwrite existing files then that's what's going to happen - no new code will be generated. Think of code generation as if you do it for the first time every time - that's basically what happens under the hood.

We plan to introduce a new feature that will automatically select entities (tables, views, etc.) that you have already generated code for so you don't have to check them again.

1 Like

Hi @korchev

Can you please elaborate more on the effects of "overwrite existing files" option when creating or updating a data source during 1) Code generation settings and 2) CRUD scaffolding steps.

Which one overwrites my custom changes on the auto-generated UI pages? and what should I do and/or avoid to do if I want to maintain both my UI changes and the code behind the UI given the following scenario:

I am updating an exiting database table with new fields and want to reflect the new fields on the UI without losing my custom UI changes.

What are the limitations in this case if any?
What happens to the auto-generated DB context service? in terms of losing crud methods? and what is the recommended approach to maintain a custom crud method?

Thanks.
Ali

This isn't supported I am afraid. Generating a new page and selecting "overwrite existing files" will do just that - overwrite the file that exists. For .cs files you can usually use partial classes which will not get overwritten. For .razor files however there is no such equivalent.

Hi @korchev ,

Thank you for your response. I appreciate the clarification. Considering the limitations you mentioned regarding the "overwrite existing files" option, I'm curious if you could provide some guidance on how I can achieve the following scenario:

I'm updating an existing database table with new fields and would like to reflect these changes on the UI without losing my custom modifications. Specifically, I'm concerned about the auto-generated DB context service and potential loss of CRUD methods.

Given the constraints, is there a recommended approach to maintain custom CRUD methods and prevent overwriting of .razor files while still reflecting database changes on the UI?

Any insights or best practices would be greatly helpful.

Thanks

You can infer a database only and not generate pages from it. This will only update the models, database context and services. Just skip the Generate pages for CRUD operations step (leave it unchecked). More info available in the Update database section of this help topic: Databases | Radzen Blazor Studio

If you don't generate CRUD pages they won't be affected by updating the data source.