Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Database Project - how to set DatabaseName variable

It's been a while sinse I used database projects and I'm tearing my hair out trying to figure out where to set the database name for this project.

I've tried in the SQLCMD variables section, but it doesn't let me (error below). I guess this section is to define your own variables (the same happens if I try $(DatabaseName))

enter image description here

The help link also doesn't work which is really helpful (goes to this dead link)

like image 646
ozz Avatar asked Dec 11 '22 19:12

ozz


1 Answers

You can override DatabaseName using one of the following methods:

  1. When using Visual Studio's publish feature, there is a Database Name field that you can change within the dialog.
  2. When publishing via the command line, sqlpackage.exe takes a TargetDatabaseName argument. Example: sqlpackage.exe /Action:Publish /SourceFile:C:\DbProject\bin\Debug\DbProject.dacpac /TargetServerName:localhost /TargetDatabaseName:TestDb (See here for all sqlpackage.exe arguments)
like image 171
Keith Avatar answered Dec 28 '22 07:12

Keith