2017-04-11 93 views
0

我正在构建一个供组织内部使用的应用程序。它连接到存储在我们数据服务器上的SQL Server CE数据库。该项目工程罚款我的机器上,但每当我试着将它部署到其他用户,我收到以下错误:实体框架和SQL Server CE - 基础提供程序失败打开

An exception occurred while initializing the database. See the InnerException for details.
at System.Data.Entity.Internal.InternalContext.PerformInitializationAction(Action action)
at System.Data.Entity.Internal.InternalContext.PerformDatabaseInitialization()
at System.Data.Entity.Internal.LazyInternalContext.b__4(InternalContext c)
at System.Data.Entity.Internal.RetryAction 1.PerformAction(TInput input)
at System.Data.Entity.Internal.LazyInternalContext.InitializeDatabaseAction(Action
1 action)
at System.Data.Entity.Internal.LazyInternalContext.InitializeDatabase()
at System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType)
at System.Data.Entity.Internal.Linq.InternalSet 1.Initialize()
at System.Data.Entity.Internal.Linq.InternalSet
1.GetEnumerator()
at System.Data.Entity.Infrastructure.DbQuery`1.System.Collections.IEnumerable.GetEnumerator()
at System.Data.Entity.QueryableExtensions.Load(IQueryable source)
at RunBKSales.Edit_Menu.Window_Loaded(Object sender, RoutedEventArgs e)

The underlying provider failed on Open.

最后一行应该是的InnerException。这是引发错误的代码:

private void Window_Loaded(object sender, RoutedEventArgs e) 
{ 
    try 
    { 
     dbContext.Combos.Load(); 
     dbContext.Products.Load(); 
     dbContext.Stores.Load(); 

     comboDataGrid.DataContext = dbContext.Combos.Local; 
     productDataGrid.DataContext = dbContext.Products.ToList(); 
     storeDataGrid.DataContext = dbContext.Stores.ToList(); 
    } 
    catch (Exception ex) 
    { 
     System.Windows.MessageBox.Show(ex.Message + " " + ex.StackTrace); 
     System.IO.File.AppendAllText(LOG_FILE, String.Format("{0} \t {1} {2} {3}", DateTime.Now.ToShortDateString(), ex.Message, ex.StackTrace, ex.InnerException.Message) + System.Environment.NewLine); 
    } 
} 

连接字符串的“数据源”是一个UNC路径.sdf数据库文件。

的App.config

<?xml version="1.0" encoding="utf-8"?> 
<configuration> 
    <configSections> 
     <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.5" /> 
    </startup> 
    <system.data> 
     <DbProviderFactories> 
      <remove invariant="System.Data.SQLite.EF6" /> 
      <add name="SQLite Data Provider (Entity Framework 6)" 
       invariant="System.Data.SQLite.EF6" 
       description=".NET Framework Data Provider for SQLite (Entity Framework 6)" 
       type="System.Data.SQLite.EF6.SQLiteProviderFactory, System.Data.SQLite.EF6" /> 
      <remove invariant="System.Data.SqlServerCe.4.0" /> 
      <add name="Microsoft SQL Server Compact Data Provider 4.0" 
       invariant="System.Data.SqlServerCe.4.0" 
       description=".NET Framework Data Provider for Microsoft SQL Server Compact" 
       type="System.Data.SqlServerCe.SqlCeProviderFactory, System.Data.SqlServerCe, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" /> 
     </DbProviderFactories> 
    </system.data> 
    <entityFramework> 
     <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlCeConnectionFactory, EntityFramework"> 
      <parameters> 
       <parameter value="System.Data.SqlServerCe.4.0" /> 
      </parameters> 
     </defaultConnectionFactory> 
     <providers> 
      <provider invariantName="System.Data.SqlClient" 
         type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" /> 
      <provider invariantName="System.Data.SqlServerCe.4.0" 
         type="System.Data.Entity.SqlServerCompact.SqlCeProviderServices, EntityFramework.SqlServerCompact" /> 
     </providers> 
    </entityFramework> 
    <connectionStrings> 
     <add name="BKSalesModel" 
      connectionString="Data Source=\\FULL\UNC\PATH\db.sdf;Persist Security Info=False;" 
      providerName="System.Data.SqlServerCe.4.0" /> 
    </connectionStrings> 
</configuration> 

再次,它的工作原理在我的机器上的罚款,所以我与调试它挣扎。任何意见,将不胜感激。

回答

0

查看根本原因错误消息的“内部异常”的内部异常!

无法通过LAN使用SQL紧凑,它是一台机器的数据库(你可以在同一台机器上的几个进程使用位于本地磁盘上的同一个数据库,虽然)

就跨共享数据局域网你应该使用SQL Server Express

相关问题