wpf - DbSet.Load() method is too slow -


i have sqlite database, contains 1 table named "main". each record of table contains 2 fields: id (integer, primary key) , name (string). there 100 records in database.

using entity framework power tools i've created code first model existing database. model rather simple:

// mainmap.cs public class mainmap : entitytypeconfiguration<main> {     public mainmap()     {         // primary key         this.haskey(t => t.id);          // properties         this.property(t => t.name)             .isrequired()             .hasmaxlength(50);          // table & column mappings         this.totable("main");         this.property(t => t.id).hascolumnname("id");         this.property(t => t.name).hascolumnname("name");     } }  // main.cs public partial class main {     public long id { get; set; }     public string name { get; set; } }  // maincontext.cs public partial class maincontext : dbcontext {     static maincontext()     {         database.setinitializer<maincontext>(null);     }      public maincontext()         : base("name=maincontext")     {     }      public dbset<main> mains { get; set; }      protected override void onmodelcreating(dbmodelbuilder modelbuilder)     {         modelbuilder.configurations.add(new mainmap());     } } 

now i'm trying records database:

maincontext context = new maincontext(); context.mains.load(); 

now can use context.mains.local comfort different purposes (actually, bind listview's itemssource).

the problem context.main.load() line executes 2.7 seconds. think, time retrieving 100 records simple database. although, i'm newcomer databases, so, maybe i'm not right , 2.7 seconds rather suitable period of time. cpu intel i3-3220 (2x3.30 ghz), entity framework's version 6.0.

maybe, code first model poor, or maybe ef doesn't provide high performance, or maybe there no need call load() method obtain records (but if don't call it, context.mains.local empty).

so, how can increase performance of getting records database?

any , hints appreciated.

i ran tests both sqlite , sql server. on laptop (corei7 2630qm 2.00ghz & win7 64bit) load time both ~1.5sec. tried warm like

context.database.exists(); 

and time reduced ~700ms both.

i used "prefer 32-bit" , "optimize code" options in build tab of project properties. these options produced best results.

try these , see if load time changes.


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -