3

我在Class Library Project的 Models 文件夹中创建了一个 EDMX 类型文件。在那个类库项目中,我将它创建为一个带有Controllers,Models,Views的 MVC 项目。在该模型文件夹中,我创建了名为 Model1.EDMX 的 EDMX 文件。当我运行项目时,会引发以下错误。我不知道为什么会这样。我的项目中只有一个 EDMX 文件。错误是:

Server Error in '/' Application.
Schema specified is not valid. Errors:
Models.Model1.csdl(3,4) : error 0019: The EntityContainer name must be unique. An EntityContainer with the name 'PivotEntities' is already defined.
Models.Model1.csdl(8,4) : error 0019: Each type name in a schema must be unique. Type name 'PivotModel.Plan_S' was already defined.
Models.Model1.csdl(16,4) : error 0019: Each type name in a schema must be unique. Type name 'PivotModel.PlanDetail' was already defined.
Models.Model1.csdl(26,4) : error 0019: Each type name in a schema must be unique. Type name 'PivotModel.PlanFeature' was already defined.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.MetadataException: Schema specified is not valid. Errors:
Models.Model1.csdl(3,4) : error 0019: The EntityContainer name must be unique. An EntityContainer with the name 'PivotEntities' is already defined.
Models.Model1.csdl(8,4) : error 0019: Each type name in a schema must be unique. Type name 'PivotModel.Plan_S' was already defined.
Models.Model1.csdl(16,4) : error 0019: Each type name in a schema must be unique. Type name 'PivotModel.PlanDetail' was already defined.
Models.Model1.csdl(26,4) : error 0019: Each type name in a schema must be unique. Type name 'PivotModel.PlanFeature' was already defined.

Source Error:


Line 12: @if (!String.IsNullOrEmpty(Model.ConfigurationActionName))
Line 13: {
Line 14:     @Html.Action(Model.ConfigurationActionName, Model.ConfigurationControllerName, Model.ConfigurationRouteValues);
Line 15: }
Line 16: else


Source File: c:\Users\rajesh.kannan\Downloads\nopcomnew\Presentation\Nop.Web\Administration\Views\Plugin\ConfigureMiscPlugin.cshtml    Line: 14

Stack Trace:


[MetadataException: Schema specified is not valid. Errors: 
Models.Model1.csdl(3,4) : error 0019: The EntityContainer name must be unique. An EntityContainer with the name 'PivotEntities' is already defined.
Models.Model1.csdl(8,4) : error 0019: Each type name in a schema must be unique. Type name 'PivotModel.Plan_S' was already defined.
Models.Model1.csdl(16,4) : error 0019: Each type name in a schema must be unique. Type name 'PivotModel.PlanDetail' was already defined.
Models.Model1.csdl(26,4) : error 0019: Each type name in a schema must be unique. Type name 'PivotModel.PlanFeature' was already defined.]
   System.Data.Metadata.Edm.EdmItemCollection.LoadItems(IEnumerable`1 xmlReaders, IEnumerable`1 sourceFilePaths, SchemaDataModelOption dataModelOption, DbProviderManifest providerManifest, ItemCollection itemCollection, Boolean throwOnError) +8404337
   System.Data.Metadata.Edm.EdmItemCollection.Init(IEnumerable`1 xmlReaders, IEnumerable`1 filePaths, Boolean throwOnError) +119
   System.Data.Metadata.Edm.EdmItemCollection..ctor(IEnumerable`1 xmlReaders, IEnumerable`1 filePaths) +157
   System.Data.Metadata.Edm.EdmMetadataEntry.LoadEdmItemCollection(MetadataArtifactLoader loader) +87
   System.Data.Metadata.Edm.EdmItemCollectionLoader.LoadItemCollection(EdmMetadataEntry entry) +12
   System.Data.Metadata.Edm.MetadataCache.LoadItemCollection(IItemCollectionLoader`1 itemCollectionLoader, T entry) +163
   System.Data.Metadata.Edm.MetadataCache.GetOrCreateEdmItemCollection(String cacheKey, MetadataArtifactLoader loader, Object& entryToken) +132
   System.Data.EntityClient.EntityConnection.LoadEdmItemCollection(MetadataWorkspace workspace, MetadataArtifactLoader artifactLoader) +103
   System.Data.EntityClient.EntityConnection.GetMetadataWorkspace(Boolean initializeAllCollections) +377
   System.Data.Objects.ObjectContext.RetrieveMetadataWorkspaceFromConnection() +25
   System.Data.Objects.ObjectContext..ctor(EntityConnection connection, Boolean isConnectionConstructor) +165
   System.Data.Objects.ObjectContext..ctor(EntityConnection connection) +61
   System.Data.Entity.Internal.InternalConnection.CreateObjectContextFromConnectionModel() +128
   System.Data.Entity.Internal.LazyInternalConnection.CreateObjectContextFromConnectionModel() +44
   System.Data.Entity.Internal.LazyInternalContext.InitializeContext() +292
   System.Data.Entity.Internal.InternalContext.Initialize() +31
   System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType) +39
   System.Data.Entity.Internal.Linq.InternalSet`1.Initialize() +137
   System.Data.Entity.Internal.Linq.InternalSet`1.get_InternalContext() +38
   System.Data.Entity.Infrastructure.DbQuery`1.System.Linq.IQueryable.get_Provider() +84
   System.Linq.Queryable.Select(IQueryable`1 source, Expression`1 selector) +66
   Nop.Plugin.Widgets.Settings.Controllers.EditController.Configure() +1300
   lambda_method(Closure , ControllerBase , Object[] ) +101
   System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) +59
   System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +435
   System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +60
   System.Web.Mvc.Async.AsyncControllerActionInvoker.InvokeSynchronousActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +50
   System.Web.Mvc.Async.<>c__DisplayClass42.<BeginInvokeSynchronousActionMethod>b__41() +75
   System.Web.Mvc.Async.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult _) +44
   System.Web.Mvc.Async.WrappedAsyncResult`1.End() +139
   System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +102
   System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult) +49
   System.Web.Mvc.Async.<>c__DisplayClass39.<BeginInvokeActionMethodWithFilters>b__33() +126
   System.Web.Mvc.Async.<>c__DisplayClass4f.<InvokeActionMethodFilterAsynchronously>b__49() +323
   System.Web.Mvc.Async.<>c__DisplayClass37.<BeginInvokeActionMethodWithFilters>b__36(IAsyncResult asyncResult) +44
   System.Web.Mvc.Async.WrappedAsyncResult`1.End() +139
   System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +102
   System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult) +50
   System.Web.Mvc.Async.<>c__DisplayClass2a.<BeginInvokeAction>b__20() +68
   System.Web.Mvc.Async.<>c__DisplayClass25.<BeginInvokeAction>b__22(IAsyncResult asyncResult) +184
   System.Web.Mvc.Async.WrappedAsyncResult`1.End() +136
   System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +56
   System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +40
   System.Web.Mvc.<>c__DisplayClass1d.<BeginExecuteCore>b__18(IAsyncResult asyncResult) +40
   System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +47
   System.Web.Mvc.Async.WrappedAsyncResult`1.End() +151
   System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +59
   System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +40
   System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +44
   System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +47
   System.Web.Mvc.Async.WrappedAsyncResult`1.End() +151
   System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +59
   System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +40
   System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +39
   System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult) +39
   System.Web.Mvc.<>c__DisplayClass8.<BeginProcessRequest>b__3(IAsyncResult asyncResult) +45
   System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +47
   System.Web.Mvc.Async.WrappedAsyncResult`1.End() +151
   System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +59
   System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +40
   System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +40
   System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +38
   System.Web.Mvc.<>c__DisplayClassa.<EndProcessRequest>b__9() +44
   System.Web.Mvc.<>c__DisplayClass4.<Wrap>b__3() +34
   System.Web.Mvc.ServerExecuteHttpHandlerWrapper.Wrap(Func`1 func) +69
   System.Web.Mvc.ServerExecuteHttpHandlerWrapper.Wrap(Action action) +123
   System.Web.Mvc.ServerExecuteHttpHandlerAsyncWrapper.EndProcessRequest(IAsyncResult result) +133
   System.Web.HttpServerUtility.ExecuteInternal(IHttpHandler handler, TextWriter writer, Boolean preserveForm, Boolean setPreviousPage, VirtualPath path, VirtualPath filePath, String physPath, Exception error, String queryStringOverride) +1464

[HttpException (0x80004005): Error executing child request for handler 'System.Web.Mvc.HttpHandlerUtil+ServerExecuteHttpHandlerAsyncWrapper'.]
   System.Web.HttpServerUtility.ExecuteInternal(IHttpHandler handler, TextWriter writer, Boolean preserveForm, Boolean setPreviousPage, VirtualPath path, VirtualPath filePath, String physPath, Exception error, String queryStringOverride) +3123183
   System.Web.HttpServerUtility.Execute(IHttpHandler handler, TextWriter writer, Boolean preserveForm, Boolean setPreviousPage) +76
   System.Web.HttpServerUtility.Execute(IHttpHandler handler, TextWriter writer, Boolean preserveForm) +28
   System.Web.HttpServerUtilityWrapper.Execute(IHttpHandler handler, TextWriter writer, Boolean preserveForm) +19
   System.Web.Mvc.Html.ChildActionExtensions.ActionHelper(HtmlHelper htmlHelper, String actionName, String controllerName, RouteValueDictionary routeValues, TextWriter textWriter) +985
   System.Web.Mvc.Html.ChildActionExtensions.Action(HtmlHelper htmlHelper, String actionName, String controllerName, RouteValueDictionary routeValues) +112
   ASP._Page_Administration_Views_Plugin_ConfigureMiscPlugin_cshtml.Execute() in c:\Users\rajesh.kannan\Downloads\nopcomnew\Presentation\Nop.Web\Administration\Views\Plugin\ConfigureMiscPlugin.cshtml:14
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +197
   System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +119
   System.Web.WebPages.StartPage.RunPage() +17
   System.Web.WebPages.StartPage.ExecutePageHierarchy() +62
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +76
   System.Web.Mvc.RazorView.RenderView(ViewContext viewContext, TextWriter writer, Object instance) +743
   System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext, TextWriter writer) +382
   System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +431
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult) +39
   System.Web.Mvc.<>c__DisplayClass1a.<InvokeActionResultWithFilters>b__17() +74
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +388
   System.Web.Mvc.<>c__DisplayClass1c.<InvokeActionResultWithFilters>b__19() +72
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +388
   System.Web.Mvc.<>c__DisplayClass1c.<InvokeActionResultWithFilters>b__19() +72
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +388
   System.Web.Mvc.<>c__DisplayClass1c.<InvokeActionResultWithFilters>b__19() +72
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +388
   System.Web.Mvc.<>c__DisplayClass1c.<InvokeActionResultWithFilters>b__19() +72
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +303
   System.Web.Mvc.Async.<>c__DisplayClass2a.<BeginInvokeAction>b__20() +155
   System.Web.Mvc.Async.<>c__DisplayClass25.<BeginInvokeAction>b__22(IAsyncResult asyncResult) +184
   System.Web.Mvc.Async.WrappedAsyncResult`1.End() +136
   System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +56
   System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +40
   System.Web.Mvc.<>c__DisplayClass1d.<BeginExecuteCore>b__18(IAsyncResult asyncResult) +40
   System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +47
   System.Web.Mvc.Async.WrappedAsyncResult`1.End() +151
   System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +59
   System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +40
   System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +44
   System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +47
   System.Web.Mvc.Async.WrappedAsyncResult`1.End() +151
   System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +59
   System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +40
   System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +39
   System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult) +39
   System.Web.Mvc.<>c__DisplayClass8.<BeginProcessRequest>b__3(IAsyncResult asyncResult) +45
   System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +47
   System.Web.Mvc.Async.WrappedAsyncResult`1.End() +151
   System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +59
   System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +40
   System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +40
   System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +38
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +9629296
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155


Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.18034 

问题是什么..?请在这个问题上帮助我。提前致谢。

4

4 回答 4

4

我已经解决了这个问题。我有两个类库项目,我在这两个项目上创建了 EDMX 文件,它们也具有与 EDMX 自动生成的“PivotEntities”相同的实体容器名称。

For eg. the two library projects named as Nop.Plugin.settings and Nop.Plugin.admin.

错误原因:

1.我在上面的项目中添加了EDMX,然后是Nop.Plugin.settings的.dll或者添加了它对MVC主项目的引用。

2.然后删除该项目的dll ( Nop.Plugin.Settings )或它从主项目或启动项目中的引用。

3.然后我添加了 Nop.Plugin.admin 项目的 .dll 或者它对 MVC 主项目的引用

4.当我运行 Main Mvc 项目时,它会抛出错误。

解决方案:

1.我去Main Mvc项目并点击显示所有文件

2.它显示了引用中的隐藏文件,在那里我找到了 Nop.Plugin.settings.dll、Nop.Plugin.settings.pdb、Nop.Plugin.admin.dll 和 Nop.Plugin.admin.pdb。3.实际上我已经从启动MVC项目中删除了项目Nop.Plugin.Setttings的引用,但它仍然驻留在导致问题的启动项目中。

所以现在我只需要 Nop.Plugin.admin 项目的 dll 和 pdb并且我在隐藏的 BIN FOLDER 中删除了 Nop.Plugin.settings.pdb 和 Nop.Plugin.settings.dll。:)

于 2013-06-14T08:03:25.667 回答
1

我也遇到了这个问题,我只是打开解决方案文件夹,从 bin 文件夹中手动删除所有 dll 和 pdb 并重建解决方案。这解决了问题。看起来当我在解决方案中跨项目重新排列模型时会导致此问题。

于 2015-02-02T01:15:11.640 回答
0

对于某些人,请清除服务器上的 bin 文件夹,然后重试。对我来说,在部署到服务器 2003 站点时出现此错误。我重命名了一个项目,旧程序集 (.dll) 在那里(在现场,而不是我的本地 bin - 我已经清理过)。由于连接字符串以“res://*;...”开头,它在所有程序集(甚至未加载的程序集)中搜索资源并找到重复项(显然)。

于 2015-03-12T21:02:05.253 回答
0

在我们的案例中,修复涉及手动编辑 edmx xml(使用“打开方式”选项将其作为 xml 文件而不是图表打开)。

如果您不提供自己的包装器,自动生成器会假定某些包装器的名称为“模型”。如果您为两个或更多实体执行此操作,这会弄乱您的整个项目。您需要修改的部分是:

<Schema Namespace="Model.Store" (there is one in the file)
<EntityContainer Name="ModelStoreContainer"> (there are two in the file)

因此,例如,您可以将它们更改为:

<Schema Namespace="WarehouseClientModel.Store" 
<EntityContainer Name="WarehouseClientModelStoreContainer"> 

如果您在所有使用未更改 Model 关键字的 edmx 文件中执行此操作,您的问题应该已经解决。

请注意,您还应该在生成 edmx 时提供自己的命名空间,或者在图表视图的属性中更改它。基本上不要依赖向导提供的任何占位符名称。

于 2014-08-15T11:05:27.967 回答