4.0实体框架项目中发生System.Data.SqlServerCe.SqlCeInvalidDatabaseFormatException [英] System.Data.SqlServerCe.SqlCeInvalidDatabaseFormatException occurred in 4.0 entity framework projects

查看:81
本文介绍了4.0实体框架项目中发生System.Data.SqlServerCe.SqlCeInvalidDatabaseFormatException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


我正面临一个异常  System.Data.SqlServerCe。 SqlCeInvalidDatabaseFormatException 与实体框架仅在4.0框架版本中的项目。此问题仅发生在4.0框架项目中,并且与其他框架相同的项目
工作正常。我刚在机器上安装了 VS2017 RC 。这个问题只发生在这台机器上。


以下代码发生异常,

 //创建一个连接对象实体连接。 
EntityConnection con = new EntityConnection(" name = NorthwindGridEntities");



我注意到,在安装VS2010的机器上没有发生此异常,VS2012,VS2013和VS2015。


以下是App.Config文件中的代码块,


< pre class ="prettyprint"><?xml version =" 1.0"编码= QUOT; UTF-8英寸;?>
< configuration>
< connectionStrings>< add name =" NorthwindGridEntities" connectionString =" metadata = res://*/Model1.csdl | res://*/Model1.ssdl | res://*/Model1.msl; provider = System.Data.SqlServerCe.3.5; provider connection string = & quot; Data Source = D:\ ImportantSampels\NorthwindGrid.sdf& quot;"的providerName = QUOT; System.Data.EntityClient" />< / connectionStrings>< / configuration>





请有人告诉我,为什么仅在VS2017 RC版本的4.0框架项目中发生此异常。



问候,




Amal Raj U

解决方案


发生此错误的原因是您对(旧)格式数据库文件使用SQL Compact 4.0提供程序。请检查文件(您可以使用我的SQL Compact Toolbox),并检查app.config文件中是否有正确的版本。


Hi All,

I am facing an exception System.Data.SqlServerCe.SqlCeInvalidDatabaseFormatException with entity framework project in 4.0 framework version only. This issue occurs only in 4.0 framework projects and the same project with other frameworks are working fine. I have just installed VS2017 RC in the machine. and this issue occurs in this machine only.

Exception occurs in the below code,

//Create a connection object for entity connection.
EntityConnection con = new EntityConnection("name=NorthwindGridEntities");

I have noticed, this exception didn't occur in a machine installed with VS2010, VS2012, VS2013 and VS2015.

Here is the code block in App.Config file,

<?xml version="1.0" encoding="utf-8"?>
<configuration>  
<connectionStrings><add name="NorthwindGridEntities" connectionString="metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;provider=System.Data.SqlServerCe.3.5;provider connection string=&quot;Data Source=D:\ImportantSampels\NorthwindGrid.sdf&quot;" providerName="System.Data.EntityClient" /></connectionStrings></configuration>


Please anyone let me know, why this exception occurs in 4.0 framework projects only with VS2017 RC build.

Regards,


Amal Raj U

解决方案

This error occurs because you are using the SQL Compact 4.0 provider against an (older) format database file. Please check the file (you can use my SQL Compact Toolbox for that), and also check that the correct version is in your app.config file.


这篇关于4.0实体框架项目中发生System.Data.SqlServerCe.SqlCeInvalidDatabaseFormatException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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