Search code examples
c#entity-frameworksql-server-cedelayloading

Problems running the program when Internet speed is low (SQL Server CE)


I have a program that works with SQL Server CE database and connects to it via EF and works on data.

The problem with this is that in the main form of the program, when trying to intialize a database type and retrieve data from the bank, if the user is connected to the Internet and the user Internet speed is low, this simple operation is about 25 to 30 It takes seconds, but the same user will be able to quickly turn off the Internet if they turn off their Internet.

This code is written in the Form Load application:

var db = new Entitites();
var count = db.User.Count();

When I run the program in VS itself, libraries that vary with Internet speed, speed of execution are DataAnnotation and System.Linq.

I've also added this code in the Entities class inherited from DbContext

public Entities(string connection)
        : base(connection)
    {
        Configuration.LazyLoadingEnabled = false;
        Configuration.AutoDetectChangesEnabled = true;
        Configuration.ProxyCreationEnabled = false;
    }

Solution

  • Is is most likely due to Invalid Internet Proxy configuration

    This appears to occur for SQL Server Compact 4.0 on any system with an invalid proxy configuration, as a Certificate Revocation List check is run each time the engine is loaded (which happens on the first call to .Open()).

    Solution: To avoid this delay, which probably affects any signed app on the system in question, you must fix the configuration or disable the check

    See my blog post here: http://erikej.blogspot.com/2013/08/faq-why-is-opening-my-sql-server.html