简体   繁体   English

将项目从.MDF数据库迁移到.SDF

[英]Migrate project from .MDF database to .SDF

I ran into a stupid problem. 我遇到了一个愚蠢的问题。

I started developing a Windows Forms application in C# that must be stand-alone (work with absolutely no installation) and needs a database. 我开始用C#开发Windows Forms应用程序,该应用程序必须是独立的(绝对无需安装即可使用)并且需要数据库。 Being genius that I am I didn't read too much into it and used SQL Server Express .MDF database. 作为我的天才,我没有读太多,而是使用SQL Server Express .MDF数据库。

Now it works perfectly, with Linq and all it's perks (data context, designer and so on) but what I didn't know is that client machine will need SQL Server installed to work with database. 现在它可以完美地与Linq及其所有特权(数据上下文,设计器等)一起使用,但是我不知道客户端计算机将需要安装SQL Server才能与数据库一起使用。 My program will be potentially deployed to 200-250 PCs and installing SQL Server on all of those PCs is not an option. 我的程序可能会部署到200-250台PC,并且不能在所有PC上安装SQL Server。

Is there any way to use a SQL Server CE database instead of .MDF ? 有什么方法可以使用SQL Server CE数据库代替.MDF Or will I have to rewrite half the program? 还是我必须重写一半的程序?

First, read about SQL LocalDB . 首先,了解SQL LocalDB It still requires installation and requires administrator rights for installation. 它仍然需要安装,并且需要管理员权限才能进行安装。 However it supports silent installs, installer size is only 33MB, and it supports the majority of the features of the full-blown SQL. 但是, 它支持静默安装,安装程序大小仅为33MB,并且支持完整SQL的大多数功能。

If you cannot afford any installs at all, then yes, SQL CE might be an option for you. 如果您根本无法负担任何安装费用,那么可以,SQL CE可能是您的选择。 Whether you'll need to rewrite half the program depends on how exactly you use your database. 是否需要重写一半的程序取决于您使用数据库的精确程度。 If you rely on stored procedures, views, raw SQL, other advanced features then yes, you might need to rewrite half of your program. 如果您依赖存储过程,视图,原始SQL,其他高级功能,那么可以,您可能需要重写一半的程序。 If you only use linq2sql with simple queries, then you might be fine and only need to rewrite the DB initialization code. 如果仅对简单查询使用linq2sql,则可能会很好,并且只需要重写DB初始化代码即可。 Remember the last visual studio that supports SQL CE tools is 2012. 请记住,最后一个支持SQL CE工具的视觉工作室是2012年。

If you can't install anything at all, and you will be rewriting half of your app — remember there're many embedded databases now days. 如果您根本无法安装任何东西,而您将重写一半的应用程序,请记住,如今有很多嵌入式数据库。

You could instead prefer SQLite : it's cross platform, extremely popular, SQL language. 相反,您可能更喜欢SQLite :它是跨平台的,非常流行的SQL语言。

Or ESENT : there's no SQL but it has tables/schema/indices/transactions, part of Windows wince win2k, the performance is really good, 10-100k requests/seconds is normal. ESENT :没有SQL,但它具有表/模式/索引/事务,是Windows wince win2k的一部分,性能确实很好,10-100k请求/秒是正常的。

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

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