Tariq Mehmood
Tariq Mehmood

Reputation: 269

Entity Framework Schema validation failure

I am trying to run a project template for ASP.NET MVC5 project which also uses Owin for authentication. The project builds successfully but when I try to create a user or perform a login or try to enable migrations, I get below error related to XML schema validation. I have tried finding the model throwing the error but could not find the model (looks like some auto generated model by Owin). The target .NET framework is 4.5.1 and the entity framework library version is 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..

Appreciate your help on the issue.

Upvotes: 2

Views: 2647

Answers (2)

SventoryMang
SventoryMang

Reputation: 10478

I would also like to chime in to this as this is the only SO related question on this I found. The name fully qualified name of where the context is matters. I had taken it out from the default spot in the IdentityModels file and put it into a folder named _Contexts. Then I got this error.

I renamed the folder to Contexts and the error went away. So possibly special characters like periods. So the same with the poster above. It appears as though underscores _ in the FQN cause the issue.

Upvotes: 0

Stefanos Chrs
Stefanos Chrs

Reputation: 2528

I had the same problem and i accedently found the solution a few minutes ago. It's the name of the solution. When I had it MVC5Example1.0 it gave me error but when I changed it to MVC5Example1 it worked. Hope it does the trick for you too.

Upvotes: 2

Related Questions