我正在尝试运行ASP.NET MVC5项目的项目模板,该模板也使用Owin进行身份验证。该项目成功构建,但是当我尝试创建用户或执行登录或尝试启用迁移时,我得到以下与XML模式验证相关的错误。我试图找到抛出错误的模型,但找不到模型(看起来像Owin的一些自动生成的模型)。目标.NET框架是4.5.1,实体框架库版本是6.0.0。
System.Data.Entity.Core.MappingException: Schema specified is not valid. Errors:
<File Unknown>(60,58) : error 2025: XML Schema validation failed for mapping schema. Schema Error Information : The 'TypeName' attribute is invalid - The value 'ASP.NET_MVC5_with_Bootstrap_3._1._1_LESS1.Models.IdentityUserClaim_User' is invalid according to its datatype 'http://schemas.microsoft.com/ado/2009/11/mapping/cs:TQualifiedName' - The Pattern constraint failed..
at System.Data.Entity.Core.Mapping.StorageMappingItemCollection.Init(EdmItemCollection edmCollection, StoreItemCollection storeCollection, IEnumerable`1 xmlReaders, IList`1 filePaths, Boolean throwOnError)
at System.Data.Entity.Core.Mapping.StorageMappingItemCollection..ctor(EdmItemCollection edmCollection, StoreItemCollection storeCollection, IEnumerable`1 xmlReaders)
at System.Data.Entity.ModelConfiguration.Edm.DbDatabaseMappingExtensions.ToStorageMappingItemCollection(DbDatabaseMapping databaseMapping, EdmItemCollection itemCollection, StoreItemCollection storeItemCollection)
at System.Data.Entity.ModelConfiguration.Edm.DbDatabaseMappingExtensions.ToMetadataWorkspace(DbDatabaseMapping databaseMapping)
at System.Data.Entity.Internal.CodeFirstCachedMetadataWorkspace..ctor(DbDatabaseMapping databaseMapping)
at System.Data.Entity.Infrastructure.DbCompiledModel..ctor(DbModel model)
at System.Data.Entity.Internal.LazyInternalContext.CreateModel(LazyInternalContext internalContext)
at System.Data.Entity.Internal.RetryLazy`2.GetValue(TInput input)
at System.Data.Entity.Internal.LazyInternalContext.InitializeContext()
at System.Data.Entity.Internal.LazyInternalContext.get_ModelBeingInitialized()
at System.Data.Entity.Infrastructure.EdmxWriter.WriteEdmx(DbContext context, XmlWriter writer)
at System.Data.Entity.Utilities.DbContextExtensions.<>c__DisplayClass1.<GetModel>b__0(XmlWriter w)
at System.Data.Entity.Utilities.DbContextExtensions.GetModel(Action`1 writeXml)
at System.Data.Entity.Utilities.DbContextExtensions.GetModel(DbContext context)
at System.Data.Entity.Migrations.DbMigrator..ctor(DbMigrationsConfiguration configuration, DbContext usersContext)
at System.Data.Entity.Migrations.DbMigrator..ctor(DbMigrationsConfiguration configuration)
at System.Data.Entity.Migrations.Design.MigrationScaffolder..ctor(DbMigrationsConfiguration migrationsConfiguration)
at System.Data.Entity.Migrations.Design.ToolingFacade.ScaffoldRunner.Run()
at System.AppDomain.DoCallBack(CrossAppDomainDelegate callBackDelegate)
at System.AppDomain.DoCallBack(CrossAppDomainDelegate callBackDelegate)
at System.Data.Entity.Migrations.Design.ToolingFacade.Run(BaseRunner runner)
at System.Data.Entity.Migrations.Design.ToolingFacade.ScaffoldInitialCreate(String language, String rootNamespace)
at System.Data.Entity.Migrations.EnableMigrationsCommand.<>c__DisplayClass2.<.ctor>b__0()
at System.Data.Entity.Migrations.MigrationsDomainCommand.Execute(Action command)
Schema specified is not valid. Errors:
<File Unknown>(60,58) : error 2025: XML Schema validation failed for mapping schema. Schema Error Information : The 'TypeName' attribute is invalid - The value 'ASP.NET_MVC5_with_Bootstrap_3._1._1_LESS1.Models.IdentityUserClaim_User' is invalid according to its datatype 'http://schemas.microsoft.com/ado/2009/11/mapping/cs:TQualifiedName' - The Pattern constraint failed..
感谢您对此问题的帮助。
答案 0 :(得分:2)
我遇到了同样的问题,几分钟前我才开始找到解决方案。 这是解决方案的名称。 当我有它MVC5Example1.0它给了我错误,但当我把它改为MVC5Example1它工作。 希望它也能帮到你。
答案 1 :(得分:0)
我还想对此进行讨论,因为这是我发现的唯一与SO相关的问题。上下文重要的名称完全限定名称。我从IdentityModels文件中的默认位置取出它并将其放入名为_Contexts的文件夹中。然后我收到了这个错误。
我将文件夹重命名为Contexts,错误消失了。所以可能是特殊字符,如句号。所以与上面的海报一样。似乎FQN中的下划线_会导致问题。