数据源相对路径



这是我pc上本地数据库的连接字符串:

<connectionStrings>
<add name="DataEntities" 
   connectionString="metadata=res://*/Data.csdl|res://*/Data.ssdl|res://*/Data.msl;
   provider=System.Data.SqlServerCe.4.0;provider connection string=&quot;
   Data Source=C:UsersUserDocumentsGitHubincidentappincidentappDatabaseData.sdf&quot;"
  providerName="System.Data.EntityClient"/>
</connectionStrings>

但是我想在计算机之间来回移动项目。我怎么能设置一个相对路径到我的数据库,如果数据库是在项目的位置,这是incidentapp.

我明白了。这是因为我正在运行调试,因此"默认"位置是在调试文件夹。因此,我只需要在开发时将数据库位置移动到调试文件夹。谢谢。

最新更新