6

I am using Entity Framework and SQL CE 4.0 with my WPF application. How do I set the maximum database size in accordance with this article, http://blogs.msdn.com/b/sqlservercompact/archive/2007/06/13/the-story-of-max-database-size-connection-string-parameter.aspx which states:

we don't always grow to 4 GB, it is not wise to allocate shared memory to accommodate all page entries/references to support 4 GB.

Currently, I get the following error when trying to add new data:

The database file is larger than the configured maximum database size.

However, the DB is only reaching close to 256MB, which is in line with the article in the link above.

2 Answers 2

8

This seems to work:

SqlCeConnectionFactory sqlCeConnection = 
    new SqlCeConnectionFactory("System.Data.SqlServerCe.4.0", 
    "", "Max Database Size=4000;Persist Security Info=False;");
DbDatabase.DefaultConnectionFactory = sqlCeConnection;
DbDatabase.SetInitializer(new SampleData());

Where the third parameter is the connection string and you change the parameter Max Database Size otherwise it defaults to 256MB.

Sign up to request clarification or add additional context in comments.

Comments

6

Alternatively using the app.config:

<entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlCeConnectionFactory, EntityFramework">
        <parameters>
            <parameter value="System.Data.SqlServerCe.4.0"/>
            <parameter value=""/>
            <parameter value="Max Database Size=4000"/>
        </parameters>
    </defaultConnectionFactory>
</entityFramework>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.