I recently upgraded my application from LINQ to SQL and SQL Server CE 3.5 to Entity Framework 4.1 Code First and SQL Server CE 4.0, and now it works much slower. I did some before and after testing the stopwatch, and most of the basic operations of my application seem to work an average of 40% slower.
I use all the default strategies and configurations for EF Code First, with the exception of disabling cascading deletes.
When I initially posted this question, I focused on one query, which seemed to take a particularly long time, but since then I realized that it was especially slow on the first start (see comment below).
Now I see that most requests are slower - not much slower, but slow enough to add up quickly, since most of the operations performed by the application are related to several requests.
This application has a very small database. The SQL CE file (.sdf) is only 458 KB, and the largest table has less than 250 entries.
Here is an example of a POCO class:
public class Target { public int Id { get; set; } public int TrialDefinitionId { get; set; } public int Number { get; set; } public int X { get; set; } public int Y { get; set; } public string Phase { get; set; } public virtual TrialDefinition TrialDefinition { get; set; } }
All my classes follow this basic pattern (simple types + virtual properties to get objects bound by foreign keys). I have one class that uses ICollection to get a list for a many-to-one relationship.
Final note. I use the repository template as an intermediary, and each repository use is put in the using block. For get operations, this causes the objects to become disconnected after receiving the data that I need from the database.
Does anyone have any specific strategies for improving the performance of my EF Code First app? . Keep in mind that I have not yet had the opportunity to read EF again. I just try to migrate from LINQ to SQL to EF as quickly and painlessly as possible. The most useful answer for me would be to change specific strategies or configurations or other settings.
c # sql-server-ce linq-to-sql entity-framework code-first
devuxer
source share