简体   繁体   English

指定的架构无效。 错误:同名的多种类型

[英]Schema specified is not valid. Errors: Multiple types with the name

I am working in EF 6 and facing the following issue when I try run my project.我在 EF 6 中工作并在尝试运行我的项目时面临以下问题。

Schema specified is not valid.指定的架构无效。 Errors:错误:

Multiple types with the name 'TableName' exist in the EdmItemCollection in different namespaces.在不同命名空间的 EdmItemCollection 中存在多个名为“TableName”的类型。 Convention based mapping requires unique names without regard to namespace in the EdmItemCollection.基于约定的映射需要唯一的名称,而不考虑 EdmItemCollection 中的命名空间。

I tried too much on StackOverFlow and google and found no solution.我在 StackOverFlow 和 google 上尝试了太多,但没有找到解决方案。 I am using visual studio 2012. I crated a single .edmx file for whole of my database.我正在使用 Visual Studio 2012。我为整个数据库创建了一个 .edmx 文件。 I searched the tableName throughout the project and there is single occurrence of table.我在整个项目中搜索了 tableName,并且只出现了一次 table。

Please help me in this regard请在这方面帮助我

Finally I figured out the solution of the problem.最后我想出了问题的解决方案。 In my question above, I stated that I have only single edmx file in my project.在我上面的问题中,我说我的项目中只有一个 edmx 文件。 It is true in one sense.从某种意义上说是对的。 But wrong in the other sense.但在另一个意义上是错误的。

I am using git to manage my code.我正在使用 git 来管理我的代码。 I created another edmx file in another project and used that project's reference in my main project.我在另一个项目中创建了另一个 edmx 文件,并在我的主项目中使用了该项目的引用。

Then I switched git branch with dll in .gitignore.然后我用 .gitignore 中的 dll 切换了 git branch。 Those dlls which were in .gitignore could not be replaced by git with the newly switched branch's dlls. .gitignore 中的那些 dll 不能被带有新切换分支的 dll 的 git 替换。 So I had two references of edmx files in my project with fully built dlls.所以我的项目中有两个 edmx 文件的引用,其中包含完全构建的 dll。

Problem solved when I keenly checked my bin folder and removed the dll which was actually not belonging to the current git branch.当我敏锐地检查我的 bin 文件夹并删除实际上不属于当前 git 分支的 dll 时,问题解决了。

I hope it will help you.我希望它会帮助你。 Comment here if some thing is not clear.如果有些事情不清楚,请在此处发表评论。 Thanks谢谢

I spend hours fixing it, tried publishing/deploying all the projects but no luck.我花了几个小时修复它,尝试发布/部署所有项目但没有运气。 So, finally found out that there was a dll that was referenced twice.所以,终于发现有一个被引用了两次的dll。 But with slightly change in name but pretty much similar content.但名称略有变化,但内容非常相似。 So, program wasn't sure which file to look at.因此,程序不确定要查看哪个文件。 I redeployed all the projects but still no luck.我重新部署了所有项目,但仍然没有运气。 So, finally deleted all the files from server except webconfig and global asax.因此,最终从服务器中删除了除 webconfig 和 global asax 之外的所有文件。 And the deployed the files again.并再次部署了文件。 Finally it worked.最后它奏效了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM