Entity Framework first Access to Database -


everytime when open database connection, first interaction database takes lot of time. second interaction on "speed" higher. think it's optimization of entity framework , looks good. it's still same if i'm working more 1 database. first interaction first database slow. first interaction second database fast. why isn't first interaction database slow too? problem initializer works first database. (i think problem caused optimization)

related question (asked myself): entity framework 6 setinitializer dbcontext not work sql server express , sql server compact

does know how optimization works , how disable it? don't work databases compare them, case nice disable optimization.

i'm wrote answer comment not appropriate.

for speed yuliam pointed link.

for rest, i'm not sure understand problem.

for me following code (pertinent extract)

class program {     static void main(string[] args) {         database.setinitializer<testefcontext>(new dropcreatedatabasealways<testefcontext>());          string cs = @"data source=aliastvalk;initial catalog=testef;integrated security=true; multipleactiveresultsets=true";         using (testefcontext ctx = new testefcontext(cs)) {             console.writeline(ctx.orders.count());         }          cs = @"data source=aliastvalk;initial catalog=testef2;integrated security=true; multipleactiveresultsets=true";         using (testefcontext ctx = new testefcontext(cs)) {             console.writeline(ctx.orders.count());         }                 } } 

well create , recreate databases testef , testef2.

did misunderstand question ?

===== response comment:

in case both databases (re)created:

  • first run: creation
  • use ssms populate data in tables
  • second run
  • check tables content ssms : tables empty <=> databases recreated @ second run.

only trivial difference case: use ef 6;


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -