Note that there are some explanatory texts on larger screens.

plurals
  1. POExponentially deteriorating performance on inserts in SQL Server Compact 4.0 tables with an Identity column
    text
    copied!<p>EDIT: the issue below has been fixed in the Entity Framework 6.</p> <p>Running the code below takes a disappointing 2 minutes and 10 seconds. Running it a second time takes 6.5 minutes. This question is related to <a href="https://stackoverflow.com/questions/14740710/is-using-a-sequential-guid-the-only-viable-alternative-to-a-database-generated/14745976#comment20661044_14745976">this one</a></p> <pre><code>Private Sub RunTest() Dim sw As New Stopwatch sw.Restart() Using db As New TestDB db.Configuration.AutoDetectChangesEnabled = False For n = 1 To 100 For m = 1 To 100 db.Tops.Add(New Top) Next Next db.SaveChanges() End Using MsgBox(sw.Elapsed.ToString) End Sub </code></pre> <p>The Entity:</p> <pre><code>Public Class Top Public Sub New() MyBase.New() One = "arerjlwkerjglwejrglwergoiwerhgiowehrowerlwelfvbwlervbowerghpiweurhgpiwuerviiervljwebbrlvjnepvjnweprvupiweurv" Two = "w;lrjgwwergkjwervgjwelrgjhwelghlwekglwergiuwehrgwjergjwervgjwerjgnwekrngpwergjpowergllwejrnglkwerngpoierhpiiuewrpjwenrwenrv;lwenrvkjernpgpsrvpi" End Sub 'ID' Public Property ID As Integer 'NATIVE PROPERTIES' Public Overridable Property One As String Public Overridable Property Two As String 'NAVIGATION PROPERTIES' End Class </code></pre> <p>Moving the Using block inside the second level interation and calling SaveChanges there makes it only worse.</p> <p>TestDB just inherits DBContext without any further configuration.When I disable database generation of the Top.ID property and supply the ID myself the performance improves a thirty fold.This problem makes using Database generated ID's in SQL Server Compact impossible. Is there a solution other than using client side generated IDs? </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload