实体框架错误 - "和EntityContainer名称必须是唯一的" [英] Entity Framework error - "The EntityContainer name must be unique"

查看:1472
本文介绍了实体框架错误 - "和EntityContainer名称必须是唯一的"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个解决方案,其中包括两个项目 - 一个控制台应用程序项目和Web应用程序项目。所有这些在架构相同,但名称不同的.edmx文件用于访问同一个数据库。

We have a solution which consists of two projects - a console application project and a web application project. Each of these has an identical in schema, but differently named .edmx file used to access the same database.

控制台应用程序运行的同一台服务器作为Web应用程序的计划任务托管。 Web应用程序中引用了作为Web应用程序导致在控制台应用程序的方法中的某些行为被称为控制台应用程序。 这种组合已经在我们的临时环境已经成功运行了好几个月。

The console application runs as a scheduled task on the same server as the web application is hosted. The web application contains a reference to the console application as certain actions within the web application lead to methods in the console application being called. This combination has been running in our staging environment successfully for many months.

在发布现场,我们每天看到以下错误信息至少一次:

When released live we are seeing the following error message at least once a day:

指定的架构是无效的。错误:

Schema specified is not valid. Errors:

ProjectName.csdl(3,4):错误0019:和EntityContainer名称必须是   独特。名称为ProjectEntities一个是EntityContainer相关已   定义。 ProjectName.csdl(63,4):错误0019:在每个类型的名称   模式必须是唯一的。类型名称ProjectModel.DataSource已经   定义。 ProjectName.csdl(75,4):错误0019:在每个类型的名称   模式必须是唯一的。类型名称ProjectModel.Error已经   定义。

ProjectName.csdl(3,4) : error 0019: The EntityContainer name must be unique. An EntityContainer with the name 'ProjectEntities' is already defined. ProjectName.csdl(63,4) : error 0019: Each type name in a schema must be unique. Type name 'ProjectModel.DataSource' was already defined. ProjectName.csdl(75,4) : error 0019: Each type name in a schema must be unique. Type name 'ProjectModel.Error' was already defined.

这继续,列出我们的架构中的所有类型的名称。

This continues, listing all the type names in our schema.

此错误可以固定通过回收应用程序池或重新启动IIS。

This error can be fixed by recycling the application pool or restarting IIS.

请注意,错误不会发生,直到Web应用程序已经运行了一段时间 - 当我们编译或我们第一次访问该应用程序是不是发生

Please note that the error does not occur until the web application has been running for a while - it is not occuring when we compile or the first time we access the application.

我最初的理论是,这两个实体容器都相互冲突,因为Web应用程序引用的控制台应用程序,但它们有不同的名称,这使和EntityContainer名称必须是唯一的错误。一个EntityContainer相关名称为 ProjectEntities已定义混淆。

My initial theory was that the two Entity Containers are conflicting with each other because the web application references the console application, but they have different names, which makes the error "The EntityContainer name must be unique. An EntityContainer with the name 'ProjectEntities' is already defined" confusing.

推荐答案

转到该bin文件夹,并删除DLL和手动PDB文件。

Go to that bin folder and delete dll and pdb file manually.

这篇关于实体框架错误 - "和EntityContainer名称必须是唯一的"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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