我正在使用SQL Server 2012作为我的系统数据库,并使用Entity Framework,Code first来访问数据库。我的数据库是本地的,但我无法使用SERVER=localhost;
在ConnectString中连接。
我的App.config
(工作正常)
<connectionStrings>
<add name="SystemContext" connectionString="Server=JOHN-PC\SQLEXPRESS;Database=PizzariaDB;user=sa;password=12345" providerName="System.Data.SqlClient"/>
</connectionStrings>
但是,如果我要在另一台计算机上安装我的系统,使用其他数据库,PC名称不是JOHN-PC,那么我需要将其更改为通用的ConnectString
。
但是,当我将JOHN-PC\SQLEXPRESS
更改为localhost
时,它无法工作。
我该怎么解决这个问题?