相关疑难解决方法(0)

如何部署SQL Server Compact Edition 4.0?

我如何部署Microsoft SQL Server Compact 4.0


SQL Server Compact Edition(目前版本为4.0)是:

免费的嵌入式数据库,软件开发人员可以使用它来构建Windows桌面应用程序.它占用空间小,支持在应用程序文件夹中私有部署其二进制文件.

但是你如何实际部署呢?

问题是除非已注册,否则无法使用ADO OLEdb提供程序.注册OLEdb提供程序必须以管理员身份完成.这意味着SQL Server Compact版本将失败,而非管理员用户.

SQL Server Compact 4.0附带一个redist_enu.txt文件:

列出的.exe文件每个都将其附带的组件安装到目标计算机上的特定位置.这有助于确保可维护性和技术支持.这些.exe文件中包含的.dll文件也可以在此redist.txt中单独使用.但是,这些单独的.dll的分发可能会导致可维护性问题.有关详细信息,请参阅http://go.microsoft.com/fwlink/?LinkId=94589

通过BreadCrumb进行私有部署检测:不支持通过Assembly.LoadFrom(),.local文件或使用DLL/COM重定向策略显式加载本机堆栈和显式加载SQL Server Compact Assembly,可能导致可维护性问题.有关详细信息,请参阅http://support.microsoft.com/kb/835322http://msdn2.microsoft.com/en-us/library/aa375142.aspx

Microsoft SQL Server Compact 4.0

SSCERuntime_x86-ENU.exe
SSCERuntime_x86-DEU.exe
SSCERuntime_x86-FRA.exe
SSCERuntime_x86-
JPN.exe SSCERuntime_x86-RUS.exe
SSCERuntime_x86-ESN.exe
SSCERuntime_x86-ITA.exe
SSCERuntime_x86-KOR.exe
SSCERuntime_x86-CHT.exe
SSCERuntime_x86-CHS.exe
SSCERuntime_x64-ENU.exe
SSCERuntime_x64-DEU.exe
SSCERuntime_x64-FRA.exe
SSCERuntime_x64-
JPN.exe SSCERuntime_x64-RUS.exe
SSCERuntime_x64-ESN.exe
SSCERuntime_x64-ITA.exe
SSCERuntime_x64-KOR.exe
SSCERuntime_x64-CHT.exe
SSCERuntime_x64-CHS.exe
sqlcese40.dll
sqlceqp40.dll …

deployment ado xcopy sql-server-2008 sql-server-ce

45
推荐指数
2
解决办法
4万
查看次数

SQLite EF6以编程方式在运行时设置连接字符串

我尝试将表单EF 3.5迁移到6(使用SQLite作为数据库).我们无法在app配置文件中设置连接字符串(这对ef6没有问题).我们必须在运行时以编程方式设置连接字符串(在用户选择SQLite文件之后).

这是我们的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>
  <connectionStrings>
    <add name="testContext" connectionString="data source=Data\testdb.sqlite;Foreign Keys=True"
      providerName="System.Data.SQLite" />
  </connectionStrings>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
      <parameters>
        <parameter value="v11.0" />
      </parameters>
    </defaultConnectionFactory>
    <providers>
      <provider invariantName="System.Data.SQLite" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6" />
    </providers>
  </entityFramework>
  <system.data>
    <DbProviderFactories>
      <remove invariant="System.Data.SQLite" />
      <remove invariant="System.Data.SQLite.EF6" />
      <add name="System.Data.SQLite" invariant="System.Data.SQLite" description=".Net Framework Data Provider for SQLite (Entity Framework 6)" type="System.Data.SQLite.EF6.SQLiteProviderFactory, System.Data.SQLite.EF6" />
    </DbProviderFactories> …
Run Code Online (Sandbox Code Playgroud)

.net sqlite connection-string runtime entity-framework-6

24
推荐指数
2
解决办法
2万
查看次数

没有App.config,EF6,SQLite将无法运行

我正在尝试制作一个插件,它将使用EF6.1和SQLite用于我无法更改App.config的应用程序,因此需要在代码中设置所有配置和连接字符串.

我发现这个答案在使用Entity Framework 6和SQLite时看起来很有前途

所以现在我有一个这样的配置类:

public class CollectionDbConfiguration : DbConfiguration
{
    public CollectionDbConfiguration()
    {
        SetProviderServices("System.Data.SQLite"(DbProviderServices)SQLiteProviderFactory.Instance.GetService(typeof(DbProviderServices)));
        SetProviderFactory("System.Data.SQLite.EF6", SQLiteProviderFactory.Instance);
        SetProviderFactory("System.Data.SQLite", SQLiteFactory.Instance);                 
    }
}
Run Code Online (Sandbox Code Playgroud)

我已经确认在第一次创建上下文之前会遇到这种情况并且所有这些都返回值.

我的上下文看起来像这样

public class MyContext : DbContext
{
    public MyContext(string connectionString)
    :   base(connectionString) { }

    public DbSet<MyEntity> MyEntities { get; set; }      
}
Run Code Online (Sandbox Code Playgroud)

我有一些代码称之为:

var context = new MyContext("Data Source = mytest.db; Version = 3;");
var entities = context.MyEntities.ToList();
Run Code Online (Sandbox Code Playgroud)

当我尝试运行代码时,看起来上下文假设连接字符串是针对SQL Server的,因为它给了我:

不支持关键字:'版本'.

如果我删除它然后我得到一个错误,它无法连接,它显然尝试连接到SQL Server数据库.

我尝试通过添加构造函数传递SQLite连接:

public MyContext(DbConnection connection) 
    : base(connection, contextOwnsConnection: true)
{ }
Run Code Online (Sandbox Code Playgroud)

并用它调用它:

var context …
Run Code Online (Sandbox Code Playgroud)

c# sqlite entity-framework-6

16
推荐指数
1
解决办法
1165
查看次数

你如何使Entity框架6 + Sqlite +代码首先工作?

我正在尝试创建一个简单的项目来探索实体框架6代码如何首先与sqlite数据库提供程序一起工作,但当我完成我的应用程序时,我得到错误:

"实体框架提供程序类型'System.Data.SQLite.SQLiteProviderServices,System.Data.SQLite.Linq,Version = 1.0.91.0,Culture = neutral,PublicKeyToken = db937bc2d44ff139'在ADO.NET提供程序的应用程序配置文件中注册无法加载不变名称'System.Data.SQLite'.请确保使用程序集限定名称并且程序集可供正在运行的应用程序使用.请参阅 http://go.microsoft.com/fwlink/?LinkId = 260882了解更多信息."

我认为这个错误与app.config文件有关.有没有人为Entity framework 6 + Sqlite 1.0.91提供有效的app.config文件?

这些是我的配置文件内容:

    <?xml version="1.0"?>
<configuration>
  <configSections>
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
  </configSections>

  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework"/>
    <providers>
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer"/>
      <provider invariantName="System.Data.SQLite" type="System.Data.SQLite.SQLiteProviderServices, System.Data.SQLite.Linq, Version=1.0.91.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139"/>
    </providers>
  </entityFramework>
  <connectionStrings>
    <add name="BloggingContext" connectionString="Data Source=.\animals.sqlite" providerName="System.Data.SQLite"/>
  </connectionStrings>
  <system.data>
    <DbProviderFactories>
      <remove invariant="System.Data.SQLite"/>
      <add name="SQLite Data Provider" invariant="System.Data.SQLite" description="Data Provider for …
Run Code Online (Sandbox Code Playgroud)

sqlite entity-framework

12
推荐指数
1
解决办法
2万
查看次数

基于 .NET 4.0 代码的配置中带有 SQLite 的 EF6:“无法确定 DbProviderFactory”

我正在尝试让 EF6 基于代码的配置与 .NET 4.0 中的 SQLite 一起使用。在我的目标应用程序中App.config是自动生成的,因此编辑非常痛苦。最初,当通过 NuGet 将 EF6 安装到 SQLite 到我的测试应用程序时,它会生成以下有效配置

<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.0,Profile=Client" />
  </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" />
    </DbProviderFactories>
  </system.data>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
      <parameters>
        <parameter …
Run Code Online (Sandbox Code Playgroud)

c# .net-4.0 ef-code-first entity-framework-6

6
推荐指数
1
解决办法
858
查看次数

没有 App.config 的 SQLite 实体框架

有必要对 3d 方应用程序插件使用 SQLite 实体框架数据库优先方法。我在互联网上搜索了所有内容,包括添加没有 App.Config 的 DbProviderFactory使用实体框架 6 和 SQLite 的问题等等。我试图以不同的方式和组合使用它们,但没有任何帮助:

“mscorlib.dll 中发生了类型为 'System.Data.Entity.Core.MetadataException' 的未处理异常。附加信息:指定的架构无效。错误:AutosuggestModel.ssdl (2,2):错误 0152:没有实体框架提供程序为具有不变名称“System.Data.SQLite.EF6”的 ADO.NET 提供程序找到。确保该提供程序已在应用程序配置文件的“entityFramework”部分中注册。”

解决方案中有一个测试控制台应用程序。使用这个最小的 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>
  <entityFramework>
    <providers>
      <provider invariantName="System.Data.SQLite.EF6" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6" />
    </providers>
  </entityFramework>
  <system.data>
    <DbProviderFactories>
      <add name="SQLite Data Provider" invariant="System.Data.SQLite" description=".NET Framework Data Provider for SQLite" type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite" />
    </DbProviderFactories>
  </system.data> …
Run Code Online (Sandbox Code Playgroud)

.net c# sqlite entity-framework app-config

5
推荐指数
1
解决办法
3152
查看次数

麻烦使用SQLite 1.0.92和Entity Framework 6.1

我正在尝试将Entity Framework与SQLite数据库文件一起使用,但无法使其正常工作.

我正在使用Visual Studio 2012,SQLite 1.0.92和Entity Framework 6.1.

edmx图正确显示我的表,所以我猜映射有效,但是当我尝试这样做时:

_Context = new DataContext();
var test = _Context.Set<T>().ToList();
Run Code Online (Sandbox Code Playgroud)

我得到以下异常:

没有为ADO.NET提供程序找到具有不变名称"System.Data.SQLite"的实体框架提供程序.确保提供程序已在应用程序配置文件的"entityFramework"部分中注册.有关详细信息,请参阅http://go.microsoft.com/fwlink/?LinkId=260882.

正如其他SO帖子中所建议的,我尝试在我的DbContext构造函数中添加它以确保复制dll:

var ensureDLLIsCopied = System.Data.Entity.SqlServer.SqlProviderServices.Instance;
Run Code Online (Sandbox Code Playgroud)

结果是,我的程序永远挂起而不是抛出和异常.

我也尝试按照此处的建议更改app.config文件,并在此帖子的接受答案中,但没有更改.

有任何想法吗?

谢谢


编辑:

我改变了我的DbContext:

public class DataContext : DbContext { }
Run Code Online (Sandbox Code Playgroud)

对此:

public class DataContext : DbContext 
{ 
    public DataContext() : base("name=Entities") { }
}
Run Code Online (Sandbox Code Playgroud)

现在,我得到的例外是:

无法在应用程序配置文件中找到"实体"连接字符串

但"实体"的连接字符串在App.config中:

<add name="Entities" 
 connectionString="metadata=res://*/Entities.Model.csdl|res://*/Entities.Model.ssdl|res://*/Entities.Model.msl;provider=System.Data.SQLite;provider connection string=&quot;data source=mypath\dbname.db&quot;"
 providerName="System.Data.EntityClient" />
Run Code Online (Sandbox Code Playgroud)

.net c# sqlite xaml entity-framework

2
推荐指数
1
解决办法
3121
查看次数