This article explains how to create and update a database using ApexSQL Model.
ApexSQL Model is a SQL database modeling tool that has the ability to create and modify tables, create new databases or modify existing ones. In this article, methods of how to create and update a database will be described in detail.
Create a database
To start creating a new database, start ApexSQL Model, click on the New button from the Home tab. When the New button is clicked, the main blank window will be shown:
Create a table
ApexSQL Model offers a very easy way to create tables. To add a new table, right-click anywhere on the main diagram, and from the right-click context menu, click on the Add table button:
The Add table window will be opened. In here, Name of the table can be given and Schema type can be chosen, along with other options such as add/delete/edit Columns, create Constraints and Indexes can be created:
When table properties are configured and the OK button is clicked, the new table will be created as shown below:
The same table can be edited and updated by right-clicking on the table and choosing the Edit option from the context menu:
The Edit table window will appear:
When objects are created, it’s time for creating a database. To do this, go to the Actions tab and click on the Create database button:
Crate database window will be opened. From the Server drop-down menu, select targeted SQL Server on which database from the model will be created:
From the Authentication drop-down menu, choose the type of Authentication.
The authentication methods are as follows:
- SQL Server
- Active Directory – Password
- Active Directory – Integrated
- Active Directory – Universal with MFA support
Enter the database name, select Collation and Compatibility level from the drop-down menu:
Once when Execute now button is clicked, creating a database process will be started.
Progress will be shown in the pop-up dialog:
The info message will be shown when the database is created:
This is an example of the created database shown in the SQL Server Management Studio:
ApexSQL Model uses ApexSQL Diff for updating a database. This tool must be installed locally.
Updating the database process is similar to creating one. The database can be loaded, and then new tables can be added, or existing ones can be edited.
To load a database, click on the Create model button from the Actions tab:
When the Create model window is opened, from the Source drop-down, select Database as the Source, the targeted Server instance, type of Authentication, and from a Database drop-down menu, select the wanted database:
When the database is loaded, after creating new objects or editing existing ones, the database can be updated by clicking the Update database button from the Actions tab:
In the Update database window, click on the Execute now button to update the database:
A database can be updated without previously loading it. To do that, start ApexSQL Model, click the Add new table button, add new tables, and then click the Update database button:
From this point on, the updating process is the same as in the previous case. Specify SQL Server and the database for the update and click the Execute now button.
This is an example of a created database using SQL database modeling tool: