Customize SQL script in "Update Database From Model" wizard?

Discussion of open issues, suggestions and bugs regarding Entity Developer - ORM modeling and code generation tool
Post Reply
lightbricko
Posts: 2
Joined: Thu 04 Jul 2013 12:05

Customize SQL script in "Update Database From Model" wizard?

Post by lightbricko » Thu 05 Sep 2013 06:03

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

Shalex
Site Admin
Posts: 8247
Joined: Thu 14 Aug 2008 12:44

Re: Customize SQL script in "Update Database From Model" wizard?

Post by Shalex » Fri 06 Sep 2013 16:46

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?

lightbricko
Posts: 2
Joined: Thu 04 Jul 2013 12:05

Re: Customize SQL script in "Update Database From Model" wizard?

Post by lightbricko » Fri 06 Sep 2013 21:48

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.

MariiaI
Devart Team
Posts: 1472
Joined: Mon 13 Feb 2012 08:17

Re: Customize SQL script in "Update Database From Model" wizard?

Post by MariiaI » Wed 11 Sep 2013 10:51

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/

edif
Posts: 2
Joined: Sat 15 Jun 2013 11:41

Re: Customize SQL script in "Update Database From Model" wizard?

Post by edif » Wed 15 Oct 2014 12:56

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.

MariiaI
Devart Team
Posts: 1472
Joined: Mon 13 Feb 2012 08:17

Re: Customize SQL script in "Update Database From Model" wizard?

Post by MariiaI » Thu 16 Oct 2014 09:46

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.

Post Reply