Is it possible to customize how the SQL script is generated in the "Update Database From Model" wizard?
Some things I want to customize:
* Order of execution
* Splitting some statements into multiple statements
* Special case handling of nullability
Customize SQL script in "Update Database From Model" wizard?
-
- Posts: 2
- Joined: Thu 04 Jul 2013 12:05
Re: Customize SQL script in "Update Database From Model" wizard?
Could you please tell us why these options are needed in your scenario? Does Entity Developer fail to execute SQL generated by default?lightbricko wrote:Some things I want to customize:
* Order of execution
* Splitting some statements into multiple statements
* Special case handling of nullability
-
- Posts: 2
- Joined: Thu 04 Jul 2013 12:05
Re: Customize SQL script in "Update Database From Model" wizard?
I would like to insert custom migration SQL code embedded in the middle of the script to migrate data in order to avoid data loss. To be able to do this in a feasible way the SQL script must be generated in a different way than Entity Developer does by default.Could you please tell us why these options are needed in your scenario?
I explained the issue on stackoverflow a while ago here: http://stackoverflow.com/questions/1680 ... ma-upgrade
No, it does not fail to execute or to update the schema. However, in many scenarios it will cause loss of data. Hence I have to write the SQL code manually in order to migrate data to new columns/tables.Does Entity Developer fail to execute SQL generated by default?
Re: Customize SQL script in "Update Database From Model" wizard?
Entity Developer doesn't provide such functionality. For these purposes special tools are used. Please pay attention to these ones for example:
http://www.devart.com/dbforge/sql/compare-bundle.html
http://www.devart.com/dbforge/sql/schemacompare/
http://www.devart.com/dbforge/sql/datacompare/
http://www.devart.com/dbforge/sql/compare-bundle.html
http://www.devart.com/dbforge/sql/schemacompare/
http://www.devart.com/dbforge/sql/datacompare/
Re: Customize SQL script in "Update Database From Model" wizard?
I don't consider an answer the reply above as it deviates from the original issue/request.
Another example reason why database script generation should be customizable is:
- adding indexes for model properties which are not keys (still missing in model first approch).
Such indexes can be added at this point by using custom attributes and for EF (or case) the IndexAttribute in System.ComponentMode.DataAnnotations.Schema can be used. The model generated can also be altered to include these using a custom DbContext.tmpl. All that remains is to be able to modify a template that generates the SQL script for update or creation of the database. Such template does not exist as far as I know. The internal code that does just that could be easily externalized into a tempalte that users of your product could customize and therefore achieve their goals before such feature are included by you.
Another example reason why database script generation should be customizable is:
- adding indexes for model properties which are not keys (still missing in model first approch).
Such indexes can be added at this point by using custom attributes and for EF (or case) the IndexAttribute in System.ComponentMode.DataAnnotations.Schema can be used. The model generated can also be altered to include these using a custom DbContext.tmpl. All that remains is to be able to modify a template that generates the SQL script for update or creation of the database. Such template does not exist as far as I know. The internal code that does just that could be easily externalized into a tempalte that users of your product could customize and therefore achieve their goals before such feature are included by you.
Re: Customize SQL script in "Update Database From Model" wizard?
Our roadmap includes an implementation of the functionality of setting indexes via Entity Developer. There is no timeframe at the moment. We will notify you when the feature is implemented.edif wrote: Another example reason why database script generation should be customizable is:
- adding indexes for model properties which are not keys (still missing in model first approch).
Please post your suggestion at our UserVoice ( http://devart.uservoice.com/forums/3867 ... -developer ) so that other users can vote for it.edif wrote:...Such template does not exist as far as I know. The internal code that does just that could be easily externalized into a tempalte that users of your product could customize and therefore achieve their goals before such feature are included by you.
Currently, it is possible to save the generated script, modify it and run it via any special tool.