“创建StoreItemCollection需要至少一个SSDL工件”实体框架出错 [英] "At least one SSDL artifact is required for creating StoreItemCollection" Error with Entity Framework

查看:164
本文介绍了“创建StoreItemCollection需要至少一个SSDL工件”实体框架出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近我在使用实体框架的ASP.NET MVC项目中收到此错误:


至少有一个SSDL工件是创建StoreItemCollection所需的


当我尝试在控制器操作中查询数据库时,会发生错误。有没有人看到这个错误?它只发生在我的一段时间,但我正在寻找解决方法。



编辑:我使用Visual Studio 2008 SP1,所以实体框架应该是版本1.我也尝试重新生成没有帮助的EDMX文件。

解决方案

我相信这个问题正在引起通过我使用的ObjectContext模式。我正在使用一个没有适用于ASP.NET MVC框架的Singleton。我相信ObjectContext在我再次尝试使用它时被处理,因此出现错误。



我已经移动到更多的ObjectContext Per Http Request模式在此博文中描述。到目前为止,这已经好多了。


I have recently been getting this error on my ASP.NET MVC project that uses the Entity Framework:

At least one SSDL artifact is required for creating StoreItemCollection

The error occurs when I try to query the database in a controller action. Has anyone seen this error before? It only occurs every once in a while for me but I am looking for ways to resolve it.

EDIT: I am using Visual Studio 2008 SP1 so the version of Entity Framework should be version 1. I have also tried regenerating the EDMX file which has not helped.

解决方案

I believe the issue was being caused by the pattern I was using with my ObjectContext. I was using a Singleton, which just didn't apply well with the ASP.NET MVC framework. I believe the ObjectContext was being disposed when I tried to use it again, hence the error.

I have moved to more of an 'ObjectContext Per Http Request' pattern, as described in this blog post. So far, this has worked much better.

这篇关于“创建StoreItemCollection需要至少一个SSDL工件”实体框架出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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