Visual Studio - Connection String for SQL Server Database Project

Viewed 3890

What is the correct way to write a connection string for a SQL Server Database Project within the same solution?

My connection string defaults as

<connectionStrings>
<add name="DefaultConnection" connectionString="Data Source=(LocalDb)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\aspnet-PokemonDayCare-20170701121228.mdf;Initial Catalog=aspnet-PokemonDayCare-20170701121228;Integrated Security=True"
  providerName="System.Data.SqlClient" />
</connectionStrings>

That LocalDB doesn't actually exist, so it creates it once it needs it (I think it does because I'm using single user authentication?).

So I need to make sure it doesn't create another database if I get the connection string wrong.

Here are the properties for my database project (it sits in the same solution as my web app).

Project Properties

  • How do I create a connection string for the database project?

(sorry if it's stupid or painfully obvious)

1 Answers
Related