Extending the answer to Yan, there is a very simple syntax if you use the Sql extension. You need both MDF and LDF (data + log files) included for your SQL database, but then attach them by referencing the same file name.
It is further assumed that the sql express server will be installed locally in the localhost \ sqlexpress instance
<Property Id="SQLINSTANCE" Value="SQLEXPRESS" /> <Property Id="SQLSERVER" Value="LOCALHOST" /> <Property Id="DATA_FOLDER" Value="C:\Program Files\Microsoft SQL Server\MSSQL11.SQLExpress\MSSQL\DATA\" /> <Component Id="Sql_Database_Deploy" NeverOverwrite="yes" Directory="[DATA_FOLDER]"> <File Source="Northwind.mdf"></File> <File Source="Northwind)log.ldf"></File> <sql:SqlDatabase Id="SqlDatabase" Database="Northwind" Server="[SQLSERVER]" Instance="[SQLINSTANCE]" CreateOnInstall="yes" DropOnUninstall="yes"> <sql:SqlFileSpec Filename="[DATA_FOLDER]Northwind.mdf" Id="Northwind_SqlFileSpec"/> <sql:SqlLogFileSpec Filename="[DATA_FOLDER]Northwind_log.ldf" Id="Northwind_SqlLogFileSpec"/> </sql:SqlDatabase> </Component>
I skipped the authentication from this example for brevity, but you can also specify the Sql user to use with the User command and referring to the identifier of the User element in the SqlDatabase attribute.
abbottdev
source share