SQLServerCE DefaultConnectionFactory

杀马特。学长 韩版系。学妹 提交于 2019-12-22 00:44:22

问题


I am using Entity Framework 4.1 and try to connect to a new SQLServerCE 4.0 database inside an MVC Web application. I am using this code

Database.DefaultConnectionFactory = new SqlCeConnectionFactory("System.Data.SqlServerCe.4.0", "|DataDirectory|", "test.sdf");

And it raises this exception :

Format of the initialization string does not conform to specification starting at index 86.

What's wrong with this code?

If I use

Database.DefaultConnectionFactory = new SqlCeConnectionFactory("System.Data.SqlServerCe.4.0")

It works and creates a database with a very long name matching my assembly name.


回答1:


A little late, but this should help:

new SqlCeConnectionFactory("System.Data.SqlServerCe.4.0", 
    "", @"Data Source=|DataDirectory|\test.sdf");


来源:https://stackoverflow.com/questions/7905076/sqlserverce-defaultconnectionfactory

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!