使用EF 4.0和SQLServerCe 3.5创建数据库 [英] Create Database with EF 4.0 and SQLServerCe 3.5

查看:87
本文介绍了使用EF 4.0和SQLServerCe 3.5创建数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试创建一个多数据库解决方案,可以根据客户需要定位Sql Server数据库或SQLCE数据库。

Trying to create a multi database solution that can either target a Sql Server database or a SQLCE database depending on client needs.

但是使用SQLCe我遇到了意外问题。

But with SQLCe I'm running into an unexpected problem.

当您调用CreateDatabase()时,您会收到ProviderIncompatibleException,并且提供程序不支持CreateDatabase消息。

When you call CreateDatabase() you get back a ProviderIncompatibleException with the message CreateDatabase is not supported by the provider.

这会导致大问题,我可以将完整的CE数据库作为嵌入式资源或文件发送,然后在需要新数据库时将其复制到客户端计算机上的所需位置,但之后我必须有效地维护数据库模式两次。

This causes a big problem, I could just ship a complete CE database as an embedded resource or file then copy it to the required location on the client machine when they need a new DB but then I have to effectively maintain the database schema twice.

是否有一种明智的方法可以解决这个问题还是我坚持使用这种方法?

Is there a sensible way round it or am I stuck with this approach?

推荐答案

Hi Matt,

Hi Matt,

目前看来,SQL CE的EF提供商不支持此功能。  作为解决方法,我们可以将SQL CE数据库保存为某些数据库脚本并在我们想要dep时执行它loy数据库在客户端。 

It seems that currently EF provider for SQL CE does not support this feature.  As a workaround, we can save the SQL CE database as some db script and execute it when we want to deploy the database at the client side. 

谢谢,b
Lingzhi Sun

Thanks,
Lingzhi Sun


这篇关于使用EF 4.0和SQLServerCe 3.5创建数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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