我正在构建一个供组织内部使用的应用程序。它连接到存储在我们数据服务器上的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.RetryAction1.PerformAction(TInput input)
1 action)
at System.Data.Entity.Internal.LazyInternalContext.InitializeDatabaseAction(Action
at System.Data.Entity.Internal.LazyInternalContext.InitializeDatabase()
at System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType)
at System.Data.Entity.Internal.Linq.InternalSet1.Initialize()
1.GetEnumerator()
at System.Data.Entity.Internal.Linq.InternalSet
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>
再次,它的工作原理在我的机器上的罚款,所以我与调试它挣扎。任何意见,将不胜感激。