在C#中创建数据库应用程序的最佳方法

时间:2022-09-15 19:47:07

I'm wondering what's the best way to create an database application using VS C# 2010 Express Edition and I have two questions:

我想知道使用VS C#2010 Express Edition创建数据库应用程序的最佳方法是什么,我有两个问题:

  1. What should I choose Microsoft SQL Server 2008 or SQL Server Compact 3.5? 2008 seems to be more complicated to install on user's desktop. If I am right, to use Compact you only need to install this server and after that application is just able to use database file.

    我应该选择哪些Microsoft SQL Server 2008或SQL Server Compact 3.5?在用户的桌面上安装2008似乎更复杂。如果我是对的,使用Compact只需安装此服务器,之后该应用程序就可以使用数据库文件了。

  2. What should I include into my package, .dll file will be enough or do I need whole for example Sql Server Compact installer?

    我应该在我的包中包含什么,.dll文件就足够了,还是我需要整个例如Sql Server Compact安装程序?

3 个解决方案

#1


6  

You may use LocalDB from new SQL Server 2012 Express. I thing it's ideal for desktop apps. More info at MSDN and SQL Server Express WebLog.

您可以使用新SQL Server 2012 Express中的LocalDB。我觉得它非常适合桌面应用。有关MSDN和SQL Server Express WebLog的更多信息。

#2


2  

Just to add, might help...
I'd suggest to use NuGet to download / install EntityFramework (type it in there and you'll get a list).
You have two versions, one regular flavor and one for compact edition.
http://nuget.org/packages/EntityFramework/4.3.1
http://nuget.org/packages/entityframework.sqlservercompact
And with that you'll get a basic 'framework' for dealing with databases as well (you'd need just to install the SqlCE (suggest 4 as is newest)) - NuGet installs the dll-s needed.
You can use 'model first' approach with EF (entity framework) to create Db first,
or even better use 'code first' approach - to create Db automatically from your code, classes.
That'd take care of creating new Db etc.
I think that's the easiest way to 'start up' with a new Db. And CE as well.
CE (compact) is a good choice - but watch, it has certain limitations comparing to the standard server SQL (express or standard etc.). E.g. you cannot use I think xml fields, and some other things, stored procedures, views etc. (If I'm correct and remember from before).
Also depends on what you want to make and where to deploy. Desktop doesn't mean that CE is best solution (depends on many details).
hope this helps

只是添加,可能有帮助...我建议使用NuGet下载/安装EntityFramework(在那里键入它,你会得到一个列表)。你有两个版本,一个是常规风味,另一个是紧凑版。 http://nuget.org/packages/EntityFramework/4.3.1 http://nuget.org/packages/entityframework.sqlservercompact随之而来的是你将获得一个处理数据库的基本“框架”(你会只需要安装SqlCE(建议4最新)) - NuGet安装所需的dll-s。您可以使用EF(实体框架)的“模型优先”方法来创建Db,甚至更好地使用“代码优先”方法 - 从您的代码,类中自动创建Db。这会照顾到创建新的Db等。我认为这是用新Db“启动”的最简单方法。和CE一样。 CE(紧凑型)是一个不错的选择 - 但是,与标准服务器SQL(快速或标准等)相比,它具有一定的局限性。例如。你不能使用我认为xml字段,以及其他一些东西,存储过程,视图等(如果我是正确的,从以前记得)。还取决于您要制作的内容和部署位置。桌面并不意味着CE是最佳解决方案(取决于许多细节)。希望这可以帮助

#3


0  

MSDN has some documentation on how to deploy SQL Server Compact with your app. It's indeed possible to both install it separately, or bundle it with your application, which is probably what you want.

MSDN有一些关于如何使用您的应用程序部署SQL Server Compact的文档。确实可以单独安装它,或者将它与您的应用程序捆绑在一起,这可能就是您想要的。

#1


6  

You may use LocalDB from new SQL Server 2012 Express. I thing it's ideal for desktop apps. More info at MSDN and SQL Server Express WebLog.

您可以使用新SQL Server 2012 Express中的LocalDB。我觉得它非常适合桌面应用。有关MSDN和SQL Server Express WebLog的更多信息。

#2


2  

Just to add, might help...
I'd suggest to use NuGet to download / install EntityFramework (type it in there and you'll get a list).
You have two versions, one regular flavor and one for compact edition.
http://nuget.org/packages/EntityFramework/4.3.1
http://nuget.org/packages/entityframework.sqlservercompact
And with that you'll get a basic 'framework' for dealing with databases as well (you'd need just to install the SqlCE (suggest 4 as is newest)) - NuGet installs the dll-s needed.
You can use 'model first' approach with EF (entity framework) to create Db first,
or even better use 'code first' approach - to create Db automatically from your code, classes.
That'd take care of creating new Db etc.
I think that's the easiest way to 'start up' with a new Db. And CE as well.
CE (compact) is a good choice - but watch, it has certain limitations comparing to the standard server SQL (express or standard etc.). E.g. you cannot use I think xml fields, and some other things, stored procedures, views etc. (If I'm correct and remember from before).
Also depends on what you want to make and where to deploy. Desktop doesn't mean that CE is best solution (depends on many details).
hope this helps

只是添加,可能有帮助...我建议使用NuGet下载/安装EntityFramework(在那里键入它,你会得到一个列表)。你有两个版本,一个是常规风味,另一个是紧凑版。 http://nuget.org/packages/EntityFramework/4.3.1 http://nuget.org/packages/entityframework.sqlservercompact随之而来的是你将获得一个处理数据库的基本“框架”(你会只需要安装SqlCE(建议4最新)) - NuGet安装所需的dll-s。您可以使用EF(实体框架)的“模型优先”方法来创建Db,甚至更好地使用“代码优先”方法 - 从您的代码,类中自动创建Db。这会照顾到创建新的Db等。我认为这是用新Db“启动”的最简单方法。和CE一样。 CE(紧凑型)是一个不错的选择 - 但是,与标准服务器SQL(快速或标准等)相比,它具有一定的局限性。例如。你不能使用我认为xml字段,以及其他一些东西,存储过程,视图等(如果我是正确的,从以前记得)。还取决于您要制作的内容和部署位置。桌面并不意味着CE是最佳解决方案(取决于许多细节)。希望这可以帮助

#3


0  

MSDN has some documentation on how to deploy SQL Server Compact with your app. It's indeed possible to both install it separately, or bundle it with your application, which is probably what you want.

MSDN有一些关于如何使用您的应用程序部署SQL Server Compact的文档。确实可以单独安装它,或者将它与您的应用程序捆绑在一起,这可能就是您想要的。