Auto-updating of schemas when starting app...

Posts   
 
    
hchattaway
User
Posts: 38
Joined: 06-Apr-2006
# Posted on: 16-Jan-2018 04:55:03   

One of the few benefits of EF is how it will automatically apply a migrations script upon startup of the application..

The UPDATE sql scripts that can be generated when a table gets changed, is there any mechanism that will automatically run these during startup of an app? Any method that will apply all changes without having to run the script in SSMS for example?

Thanks! Harold

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 16-Jan-2018 10:00:13   

Not at the moment. the main reason is that in general people tend to create test migrations first before migrating live systems to a new schema version. Only in cleanroom situations where there's no data in the database it's often desirable to immediately run updates. This is why the scripts are produced as sql scripts and aren't executed at startup.

Frans Bouma | Lead developer LLBLGen Pro
hchattaway
User
Posts: 38
Joined: 06-Apr-2006
# Posted on: 16-Jan-2018 19:16:30   

Hi Frans,

ok, for the current app here at work, that would be an issue.. it's a WPF app running on a laboratory robot and when updates are sent out to the field, they are updated via the EF mechanism... agreed, can be problematic, but that's the workflow..

Wouldn't be to tough to create the ability to run through an update script created by LLBLGen though...

Thanks! Harold

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 17-Jan-2018 09:57:00   

It's not that hard to do though: the script contains 'go' separator statements at the start of the line. So read lines from the update script till you see a line with just 'go', then execute what you read through a Sqlcommand, skip the go line and proceed with the next lines.

Frans Bouma | Lead developer LLBLGen Pro