Ashutosh
Ashutosh

Reputation: 4675

Entity Framework SDF database size issue

I am using SQL Server Compact edition with Entity Framework for one of my project. I'm reading files from server and saving it to my database. The problem is that database size becomes big (i.e. exceeds the max database size) and application crashes with the message:

entity framework underlying provider failed on open
database exceeds max size

I read from various sites and tried to add:

Max Database Size=1024

to my connection string but it says keyword not supported. I do not want to use .mdf as client has to install SQL Server also.

Here is my connection string:

<add name="Entities" 
     connectionString="metadata=res://*/DBModel.csdl|res://*/DBModel.ssdl|res://*/DBModel.msl;provider=System.Data.SqlServerCe.4.0;provider connection string=&quot;data source=|DataDirectory|\DB.sdf&quot;" 
     providerName="System.Data.EntityClient" />

Upvotes: 1

Views: 1010

Answers (1)

ErikEJ
ErikEJ

Reputation: 41749

Change connection string:

<add name="Entities" 

  connectionString="metadata=res://*/DBModel.csdl|res://*/DBModel.ssdl|res://*/DBModel.msl;provider=System.Data.SqlServerCe.4.0;provider connection string=&quot;data source=|DataDirectory|\DB.sdf;Max database size=4091&quot;" 
 providerName="System.Data.EntityClient" />

Also note that the max size for a SQL Compact database is 4 GB

Upvotes: 3

Related Questions