Page 1 of 1
Customize SQL script in "Update Database From Model" wizard?
Posted: Thu 05 Sep 2013 06:03
by lightbricko
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
Re: Customize SQL script in "Update Database From Model" wizard?
Posted: Fri 06 Sep 2013 16:46
by Shalex
lightbricko wrote:Some things I want to customize:
* Order of execution
* Splitting some statements into multiple statements
* Special case handling of nullability
Could you please tell us why these options are needed in your scenario? Does Entity Developer fail to execute SQL generated by default?
Re: Customize SQL script in "Update Database From Model" wizard?
Posted: Fri 06 Sep 2013 21:48
by lightbricko
Could you please tell us why these options are needed in your scenario?
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.
I explained the issue on stackoverflow a while ago here:
http://stackoverflow.com/questions/1680 ... ma-upgrade
Does Entity Developer fail to execute SQL generated by default?
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.
Re: Customize SQL script in "Update Database From Model" wizard?
Posted: Wed 11 Sep 2013 10:51
by MariiaI
Re: Customize SQL script in "Update Database From Model" wizard?
Posted: Wed 15 Oct 2014 12:56
by edif
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.
Re: Customize SQL script in "Update Database From Model" wizard?
Posted: Thu 16 Oct 2014 09:46
by MariiaI
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).
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:...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.
Please post your suggestion at our UserVoice (
http://devart.uservoice.com/forums/3867 ... -developer ) so that other users can vote for it.
Currently, it is possible to save the generated script, modify it and run it via any special tool.