Embedding SQL Scripts in Our Project
Explore embedding SQL scripts as project resources to enable automated database migrations using DbUp and Dapper. Understand how to organize scripts, execute migrations, and maintain schema versioning to keep your database synchronized with your application.
We'll cover the following...
In the previous subsection, we told DbUp to look for SQL Scripts that have been embedded in our project. Now, we are going to embed SQL Scripts for the tables and stored procedures in our project so that DbUp will execute them if they haven’t already been executed when our app loads:
In “Solution Explorer”, right-click the project and choose “Add | New Folder”. Enter “SQLScripts” as the folder name.
Right-click the “SQLScripts” folder and choose “Add | New Item…”
In the dialog box that appears, select the “General” tab and then “Text File” and enter
01-Tables.sqlas the filename: