LocalDatabase-安装程序安装问题

时间:2019-06-28 11:04:56

标签: c# connection-string setup-project local-database

我有带有本地数据库的c#winfrm项目。我创建了带有附加数据库的安装文件。 但是我得到以下错误。 发生文件激活错误。物理文件名“ InventoryDb.mdf”可能不正确。诊断并更正其他错误,然后重试该操作。

它与我拥有项目的计算机在同一台计算机上都可以正常工作,但在Windows 7安装该软件时却无法正常工作。 这是我在App.config页面中的连接字符串

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
  </configSections>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
  </startup>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
      <parameters>
        <parameter value="mssqllocaldb" />
      </parameters>
    </defaultConnectionFactory>
    <providers>
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
    </providers>
  </entityFramework>
  <connectionStrings>
    <add name="Db"  connectionString="Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\InventoryDb.mdf;Integrated Security=True;Connect Timeout=30; MultipleActiveResultSets=True"
    providerName="System.Data.SqlClient"  /> 
  </connectionStrings>
</configuration>

我想知道我在想什么?我的连接字符串是否错误?我恳请您的帮助。

0 个答案:

没有答案