问题
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