Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy is EF4 Code First so slow when storing objects?
    primarykey
    data
    text
    <p>I'm currently doing some research on usage of db4o a storage for my web application. I'm quite happy how easy db4o works. So when I read about the Code First approach I kinda liked is, because the way of working with EF4 Code First is quite similar to working with db4o: create your domain objects (POCO's), throw them at db4o, and never look back.</p> <p>But when I did a performance comparison, EF 4 was horribly slow. And I couldn't figure out why.</p> <p>I use the following entities :</p> <p><pre><code></p> <p>public class Recipe { private List _RecipePreparations; public int ID { get; set; } public String Name { get; set; } public String Description { get; set; } public List Tags { get; set; } public ICollection Preparations { get { return _RecipePreparations.AsReadOnly(); } }</p> <pre><code> public void AddPreparation(RecipePreparation preparation) { this._RecipePreparations.Add(preparation); } } </code></pre> <p>public class RecipePreparation { public String Name { get; set; } public String Description { get; set; } public int Rating { get; set; } public List Steps { get; set; } public List Tags { get; set; } public int ID { get; set; } }</p> <p></pre></code></p> <p>To test the performance I new up a recipe, and add 50.000 RecipePrepations. Then I stored the object in db4o like so : </p> <pre><code>IObjectContainer db = Db4oEmbedded.OpenFile(Db4oEmbedded.NewConfiguration(), @"RecipeDB.db4o"); db.Store(recipe1); db.Close(); </code></pre> <p>This takes around 13.000 (ms)</p> <p>I store the stuff with EF4 in SQL Server 2008 (Express, locally) like this :</p> <pre><code>cookRecipes.Recipes.Add(recipe1); cookRecipes.SaveChanges(); </code></pre> <p>And that takes 200.000 (ms)</p> <p>Now how on earth is db4o 15(!!!) times faster that EF4/SQL? Am I missing a secret turbo button for EF4? I even think that db4o could be made faster? Since I don't initialize the database file, I just let it grow dynamically.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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