I currently working on a application that use Entity Framework 4.1 (code first) and SQL Server CE 4.0. One of the new things I really like from SQL Server CE 4.0 are the computed values.
But I have some performance problem while importing old data into my new data store system (around 50000 entries). This is my second implementation for this. The first version used Entity Framework 4.0 and SQL Server CE 3.5. But there is a huge performance difference between these implementations. The code first implementation takes around one hour to import the entries, the other implementation only some minutes.
The most time is spend in the SaveChanges
method. I tracked the problem down to the [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
attribute. If I use [DatabaseGenerated(DatabaseGeneratedOption.None)]
and implement my own generation of keys (as a simple workaround) the performance is back on the level of the first implementation.
Is this a known problem? Is there any way to solve this performance problem? Or is generating my own keys the way to go?