实体框架 - 在不同的enviroments不同的行为 [英] Entity Framework - Different behavior on different enviroments

查看:111
本文介绍了实体框架 - 在不同的enviroments不同的行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近开始与实体框架(4.1版)和WCF工作。
我试图做一个n层asp.net应用程序(.NET Framework 4.0中),其中数据层由在内部使用实体框架的WCF服务。与实体框架采用的方法模型第一。

I've recently started working with Entity Framework (version 4.1) and WCF. I'm trying to make an n-tier asp.net application (.Net Framework 4.0), in which the data-layer consists of wcf services that internally use the entity-framework. The approach taken with the entity framework is model-first.

在我的开发环境,我对IIS 7.5运行在相同的网站,并在同一个应用程序池下两个asp.net应用程序和WCF服务的(这不是很大,但它的工作原理)。在任何的WCF服务的第一次访问,表现相当差,但在随后的访问它的确定。用于在第一接入性能不良的原因,被解释此处 - 例如与视图生成相关的开销,美元查询的对$ pparation等,

On my development environment i have both the asp.net application and the wcf services running on the IIS 7.5 under the same web site and under the same application pool (It's not great but it works). On the first access of any of the wcf services, the performance is quite poor, but on subsequent accesses it's OK. The reasons for the bad performance on the first access, are explained here - e.g. the overhead associated with the view generation, preparation of the queries, etc,

完成开发后,我已经建立了一个测试环境与2虚拟机 - 一台服务器(IIS 7.5)托管应用程序前端和承载WCF服务的另一个(再次IIS 7.5) - 在不同的运行机,在不同的网站,不同的应用程序池。

After completing the development, I've set up a testing environment with 2 virtual machines - one server (IIS 7.5) that hosts the application front-end and another one (again IIS 7.5) that hosts wcf services - running in different machines, under different websites and different application pools.

我期待相同的行为,即执行速度快了很多的服务和后续访问一个缓慢的第一次访问,但所有访问该服务运行缓慢。

I was expecting the same behavior, namely a slow first access to the services and subsequent accesses executing a lot faster, but all accesses to the services run slow.

问题是不是与查询是沉重的,它不与网络有问题。我已经执行的实体框架的分析工具,并产生了意见,并在每次调用WCF服务存在疑问的preparation显然开销。查询的执行跑得快。

The problem is not with the queries being heavy and it's not a problem with the network . I have executed an entity framework profiling tool, and apparently the overhead of generating the views and the preparation of queries exists on every call to the wcf service. The execution of the queries runs fast.

基本上我试图找出为什么我在不同的环境中注意到不同的行为。

Essentially I'm trying to figure out why I am noticing different behaviors on different environments.

从我读过的东西,每次创建一个AppDomain的时候,实体框架执行与该初始开销相关的操作。但这是否意味着每次调用创建一个新的AppDomain WCF服务?

From what I've read, every time an AppDomain is created, the entity-framework executes the operations that are associated with the initial overhead. But does this mean for every call to a WCF service a new AppDomain is created?

我AP preciate任何见解任何人都可以提供我在这件

I appreciate any insight anyone can provide me on this one

感谢

推荐答案

我想通了。显然,开发机的安装有安装.NET Framework的2011年6月CTP和测试环境的机器有标准框架4.0。我已经升级到.NET Framework 4.5上所有的机器,一切现在将按预期。

I figured it out. Apparently the setup of the development machine had the June 2011 CTP of the .Net Framework installed, and the test environment machines had the standard .Net Framework 4.0. I have upgraded to .Net Framework 4.5 on all of the machines, and everything now works as expected.

显然,实体框架的.NET 4.0,在每次请求介绍了如何生成的意见和编译查询的开销。在4.2版的框架和上述情况,行为更像是什么在文献中描述的:开销仅出现在第一接入

Apparently the Entity Framework on .Net 4.0, on every request introduces the overhead of generating the views and compiling the queries. On the 4.2 version of the Framework and above, the behavior is more like what is described on the literature: the overhead only occurs on the first access.

在WCF的AppDomain由IIS应用程序池创建,并在多个请求被重用。

The WCF AppDomain is created by the IIS Application Pool and is reused on several requests.

我AP preciate您输入纳拉亚纳

I appreciate your input Narayana

这篇关于实体框架 - 在不同的enviroments不同的行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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