- #Dbschema ways to write how to#
- #Dbschema ways to write update#
- #Dbschema ways to write upgrade#
- #Dbschema ways to write code#
Now, we will implement the necessary steps for the code execution:Īnd that is all - all database changes are executed automatically, only in the case that they were not already executed.
#Dbschema ways to write upgrade#
So, let's prepare a simple upgrade script with an alternative statement for two different database engines (you can find it in the DbKeeperNet.Demo project as the file DatabaseSetup.xml): My favorite way to implement an upgrade script is by using an XML file stored as an embedded resource in an assembly. If you want to directly execute the demo project, you need the SQL Server 2005 Express Edition installed, or you must change the connection string in App.Config.įor more complex scenarios, you can check the DbKeeperNet.ComplexDemo project (there is an example of a custom step implementation, split XML scripts, etc.). The code snippets below are taken from the DbKeeperNet.SimpleDemo project. This allows you to very simply search the database and check which steps were already executed. The database service implementation simply keeps track of these already executed steps (concrete implementation is strongly dependent on the used database service).
#Dbschema ways to write update#
#Dbschema ways to write how to#
There are two basic principles on how to get your application's database schema up-to-date: