"要求创建StoreItemCollection&QUOT至少有一个SSDL神器;错误与实体框架 [英] "At least one SSDL artifact is required for creating StoreItemCollection" Error with Entity Framework

查看:209
本文介绍了"要求创建StoreItemCollection&QUOT至少有一个SSDL神器;错误与实体框架的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近一直得到使用实体框架在我的ASP.NET MVC项目这个错误:

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

至少一个SSDL工件需要创建StoreItemCollection

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.

编辑:我使用Visual Studio 2008 SP1使实体框架的版本应该是第1版。我也试图再生已经没有帮助EDMX文件

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.

推荐答案

我相信这个问题正在被我用我的ObjectContext模式造成的。我使用的是单身,这只是没有与ASP.NET MVC框架也适用。我相信,当我试图再次使用它ObjectContext中被布置,因此错误。

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.

我已经转移到更多的ObjectContext的每HTTP请求模式,如在的这个博客帖子。到目前为止,这工作要好得多。

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&QUOT至少有一个SSDL神器;错误与实体框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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