六秒预热时间为第一个实体框架6非查询 [英] Six seconds warmup time for the first entity framework 6 nonquery

查看:112
本文介绍了六秒预热时间为第一个实体框架6非查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  // Act 
秒表w =新的秒表();
w.Start();
userService.Create(userDTO);
w.Stop();


public void Create(UserDTO userDTO)
{
var user = userDTO.ToEntity();
_context.Entry(user).State = EntityState.Added;
_context.SaveChanges();
}

6,2秒做一个sql insert是疯狂的。我们已经看到应用程序用户在第一次打开他们全年使用的项目时抱怨。所以每天他们都要等6秒...



我以为EF6的预热时间有所改善?



有什么可以做的,以改善这种悲惨的行为?

解决方案

尝试 EF6 CodeFirst View Generation T4 Template for C#。预生成的视图通过将必须在运行时完成的工作移动到设计时间来提高应用程序启动时间。 更多信息


From my integration test:

// Act
Stopwatch w = new Stopwatch();
w.Start();
userService.Create(userDTO);
w.Stop();


public void Create(UserDTO userDTO)
{
    var user = userDTO.ToEntity();
    _context.Entry(user).State = EntityState.Added;
    _context.SaveChanges();
}

6,2 seconds to do an "sql insert" is crazy. I already see the application users complaining when they first open a project which they use the whole year. So everyday they have to wait 6 seconds...

I thought the warm up time in EF6 has improved?

Is there anything I can do to improve this miserable behavior?

解决方案

Try EF6 CodeFirst View Generation T4 Template for C#. Pre-generated views improve application start-up time by moving the work that would have to be done at runtime to design time. more info

这篇关于六秒预热时间为第一个实体框架6非查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆