[英]Why can't SQL Server Compact Edition open an existing SDF file if my connection string contains the max database size keyword?
I keep seeing this exception: 我一直看到这个异常:
ex = {"Keyword not supported: 'max database size'."} ex = {“不支持关键字:“最大数据库大小”。”}
When I try running the following code (exception is thrown on the LINQ query line): 当我尝试运行以下代码时(在LINQ查询行上引发了异常):
LogContext l = new LogContext(connectionString);
var v = from log in l.Logs select log;
count += v.Count();
The LogContext
class looks like this: LogContext
类如下所示:
public class LogContext : DbContext
{
public LogContext()
: base()
{
}
public LogContext(string connectionString)
: base(connectionString)
{
}
public DbSet<LogRecord> Logs { get; set; }
}
My connection string contains the Max Database Size
property. 我的连接字符串包含“ Max Database Size
属性。 Is there a reason why its throwing this exception? 它引发此异常有原因吗? Does SQL Server Compact Edition use the Max Database Size
property only once for creating the database and stores this information in the local file or something, such that I can't connect to this file when I specify this property thereafter? SQL Server Compact Edition是否仅使用一次“ Max Database Size
属性来创建数据库,并将此信息存储在本地文件或其他内容中,这样以后在指定此属性后便无法连接到该文件? Because this all works when I create new databases. 因为当我创建新数据库时,所有这些都有效。
Setting the DefaultConnectionFactory seemed to work for me: 设置DefaultConnectionFactory似乎对我有用:
Database.DefaultConnectionFactory = new SqlCeConnectionFactory("System.Data.SqlServerCe.4.0"); Database.DefaultConnectionFactory =新的SqlCeConnectionFactory(“ System.Data.SqlServerCe.4.0”);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.