简体   繁体   English

SQL Server CE分发

[英]SQL Server CE distribution

I have spent several days trying to solve this problem with no luck and my requirements are really simple - I want to make an application with database which will work on most PCs (without DB server installed) and I want to use LINQ . 我花了几天的时间来解决这个问题,但运气并不好,我的要求确实很简单-我想创建一个具有数据库的应用程序,该数据库在大多数PC上都可以运行(未安装DB服务器),并且我想使用LINQ For the compatibility reasons I want to use .NET framework 3.5 (every Windows 7 machine has it). 出于兼容性原因,我想使用.NET Framework 3.5 (每台Windows 7计算机都具有)。

I have tried 2 ways: SQL Server CE and SQLite. 我尝试了2种方法:SQL Server CE和SQLite。

SQL Server CE SQL Server CE

Although Visual Studio does not support LINQ for Compact Version of SQL server, I have found simple workaround - generating .dbml file using metal.exe tool from Visual Studio and then dragging it into project. 尽管Visual Studio不支持SQL Server精简版LINQ,但我发现了一种简单的解决方法-使用Visual Studio中的metal.exe工具生成.dbml文件,然后将其拖动到项目中。 My application works fine on my machine, but when I copy it somewhere else, it crashes. 我的应用程序可以在我的机器上正常工作,但是当我将其复制到其他地方时,它崩溃了。 I have copied all dlls from C:\\Program Files (x86)\\Microsoft SQL Server Compact Edition\\3.5 and tried 4.0 too. 我已经从C:\\ Program Files(x86)\\ Microsoft SQL Server Compact Edition \\ 3.5复制了所有dll,并尝试了4.0。 I think problem is that my app is not looking for dlls (references) inside its directory. 我认为问题是我的应用程序不在其目录内查找dll(引用)。 I managed to get it work using DataSets (without LINQ), where I manually add reference to SQLServerCE and check CopyLocal to true. 我设法使用DataSets(没有LINQ)使它工作,在这里我手动添加了对SQLServerCE的引用,并将CopyLocal设置为true。 BUT when I use LINQ, there is no reference to SQLServerCE in project references and it is working. 但是,当我使用LINQ时,在项目引用中没有对SQLServerCE的引用,并且它正在运行。 I don't know how to change it. 我不知道该如何更改。 Or is there a problem somewhere else? 还是其他地方有问题?

SQLite SQLite的

After long messing with SQL Server CE, I have tried SQLite. 与SQL Server CE长期混乱之后,我尝试了SQLite。 I am very disappointed how poor is SQLite support in .NET. 我非常失望。NET对SQLite的支持多么糟糕。 I had to download older version of ADO.NET provider (newer versions does not add SQLite Database into my Visual Studio 2010 - I don't understand why but I googled that it is normal and I have to install old version and then replace it with newer). 我必须下载旧版本的ADO.NET提供程序(新版本未将SQLite数据库添加到我的Visual Studio 2010中-我不知道为什么,但是我用谷歌搜索它是正常的,因此我必须安装旧版本,然后将其替换为较新)。 Then I downloaded dblinq (I have discovered that this project is dead later) and after some messing with dbmetal and dlls I get rid of errors in Visual Studio and compiled my application. 然后,我下载了dblinq(我发现这个项目后来死了),在弄乱了dbmetal和dll之后,我摆脱了Visual Studio中的错误并编译了我的应用程序。 But I can't run it, it always crashes on error 40 - like there was no SQLite server. 但是我无法运行它,它总是在错误40上崩溃-就像没有SQLite服务器一样。 Of course I have copied all dlls. 当然,我已经复制了所有dll。 I can't run it even on my development machine. 即使在我的开发机器上,我也无法运行它。

I am very surprised that it is nearly impossible to create simple database application in C# .NET which will not bother client with servers etc. 令我感到非常惊讶的是,几乎不可能在C#.NET中创建简单的数据库应用程序,它不会打扰客户端与服务器等。

Please is there anyone who made SQL CE work with LINQ and mainly who made his app distributable? 请问有人使SQL CE与LINQ一起工作,主要是使他的应用程序可分发吗?

I would suggest you try using the nuget Entity Framework for SQL CE package. 我建议您尝试使用nuget Entity Framework for SQL CE软件包。 It will download all the required assemblies to make it work. 它将下载所有必需的程序集以使其正常运行。 http://nuget.org/packages/EntityFramework.SqlServerCompact/ http://nuget.org/packages/EntityFramework.SqlServerCompact/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM