使用实体框架与SQL Compact专用安装 [英] Using Entity Framework with an SQL Compact Private Installation

查看:149
本文介绍了使用实体框架与SQL Compact专用安装的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用SQL Compact的桌面应用程序中使用了Entity Framework 4。我想使用我的应用程序的SQL Compact的专用安装,以便我的安装程序可以安装SQL Compact,而不需要用户进行第二次安装。它也避免了路上的版本控制麻烦。

I am using Entity Framework 4 in a desktop application with SQL Compact. I want to use a private installation of SQL Compact with my application, so that my installer can install SQL Compact without giving the user a second installation to do. It also avoids versioning hassles down the road.

我的开发机器已经安装了SQL Compact 3.5 SP1作为公共安装,所以我的应用程序运行良好,正如人们所期待的那样。但是它没有在我的测试机上运行,​​没有安装SQL Compact。我收到此错误:

My development machine has SQL Compact 3.5 SP1 installed as a public installation, so my app runs fine there, as one would expect. But it's not running on my test machine, which does not have SQL Compact installed. I get this error:

The specified store provider cannot be found in the configuration, or is not valid.

我知道有些人在SQL Compact专用安装中遇到困难,但是我已经使用了一段时间,我真的很喜欢他们。不幸的是,我的常规私人安装方法不起作用。我已经检查了我的SQL CE文件的版本号,它们都是3.8.8078.0,这是SP2 RC版本。

I know some people have had difficulty with SQL Compact private installations, but I have used them for a while, and I really like them. Unfortunately, my regular private installation approach isn't working. I have checked the version numbers on my SQL CE files, and they are all 3.8.8078.0, which is the SP2 RC version.

这里是我包含的文件我的私人安装:

Here are the files I have included in my private installation:


  • sqlcecompact35.dll

  • sqlceer35EN.dll

  • sqlceme35.dll

  • sqlceqp35.dll

  • sqlcese35.dll

  • System.Data。 SqlServerCe.dll

  • System.Data.SqlServerCe.Entity.dll

  • sqlcecompact35.dll
  • sqlceer35EN.dll
  • sqlceme35.dll
  • sqlceqp35.dll
  • sqlcese35.dll
  • System.Data.SqlServerCe.dll
  • System.Data.SqlServerCe.Entity.dll

我添加了引用System.Data.SqlServerCe到我的项目,我已经验证了上面列出的所有文件都被复制到安装机器上的应用程序文件夹。

I have added a reference to System.Data.SqlServerCe to my project, and I have verified that all of the files listed above are being copied to the application folder on the installation machine.

这里是我打开一个SQL Compact文件时用来配置EntityConnectionStringBuilder的代码:

Here is the code I use to configure an EntityConnectionStringBuilder when I open a SQL Compact file:

var sqlCompactConnectionString = string.Format("Data Source={0}", filePath);

// Set Builder properties
builder.Metadata = string.Format("res://*/{0}.csdl|res://*/{0}.ssdl|res://*/{0}.msl", edmName);
builder.Provider = "System.Data.SqlServerCe.3.5";
builder.ProviderConnectionString = sqlCompactConnectionString;
var edmConnectionString = builder.ToString();

我缺少一个文件?我错过了配置步骤,需要告诉Entity Framework哪里可以找到我的SQL Compact DLL?任何其他建议,为什么EF没有在安装机器上找到我的SQL Compact DLL?感谢您的帮助。

Am I missing a file? Am I missing a configuration stepp needed to tell Entity Framework where to find my SQL Compact DLLs? Any other suggestions why EF isn't finding my SQL Compact DLLs on the installation machine? Thanks for your help.

推荐答案

我想出了如何做,感谢一个史蒂夫博客拉斯克。基本上,这里是你必须做的:

I figured out how to do it, thanks to a blog post by Steve Lasker. Basically, here is what you have to do:

(1)设置引用 System.Data.SqlServerCe.dll 在你的项目。将 CopyLocal 属性设置为True。

(1) Set a reference to System.Data.SqlServerCe.dll in your project. Set the CopyLocal property to True.

(2)在项目的App.config中,添加以下内容XML标记它告诉EntityFramework查看您的私人安装SQL Compact的数据提供者:

(2) In the App.config for your project, add the following XML markup. It tells EntityFramework to look to your private installation of SQL Compact for its data provider:

<system.data>
    <DbProviderFactories>
        <remove invariant="System.Data.SqlServerCe.3.5"/>
        <add name="Microsoft SQL Server Compact Data Provider" invariant="System.Data.SqlServerCe.3.5" description=".NET Framework Data Provider for Microsoft SQL Server Compact" type="System.Data.SqlServerCe.SqlCeProviderFactory, System.Data.SqlServerCe, Version=3.5.1.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91"/>
    </DbProviderFactories>
</system.data>

(3)在安装项目中,将以下文件添加到文件系统编辑器中的应用程序文件夹:

(3) In the Setup project, add the following files to the Application Folder in the File System Editor:


  • sqlcecompact35.dll

  • sqlceme35.dll

  • sqlcese35.dll

  • System.Data.SqlServerCe.Entity.dll

  • sqlcecompact35.dll
  • sqlceme35.dll
  • sqlcese35.dll
  • System.Data.SqlServerCe.Entity.dll

这篇关于使用实体框架与SQL Compact专用安装的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆