Multi time generate code issue


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?

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?


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.