2013-01-03 87 views
0

我只是想从EF 4.3升级到EF在.NET 4.0迁移的EF 5否则从EF升级后4.3

5,而当我运行使用update-database的迁移,我得到这个:

System.Data.MetadataException: Schema specified is not valid. Errors: 
(0,0) : warning 0005: Could not find schema information for the attribute 'Namespace'. 
(0,0) : warning 0005: Could not find schema information for the attribute 'Provider'. 
(0,0) : warning 0005: Could not find schema information for the attribute 'ProviderManifestToken'. 
(0,0) : warning 0005: Could not find schema information for the attribute 'Alias'. 
(0,0) : error 0010: The element Schema in namespace http://schemas.microsoft.com/ado/2009/11/edm/ssdl was unexpected for the root element. The expected Schema in one of the following namespaces: http://schemas.microsoft.com/ado/2006/04/edm/ssdl, http://schemas.microsoft.com/ado/2009/02/edm/ssdl. 
    at System.Data.Metadata.Edm.StoreItemCollection.Loader.ThrowOnNonWarningErrors() 
    at System.Data.Metadata.Edm.StoreItemCollection.Loader.LoadItems(IEnumerable`1 xmlReaders, IEnumerable`1 sourceFilePaths) 
    at System.Data.Metadata.Edm.StoreItemCollection.Init(IEnumerable`1 xmlReaders, IEnumerable`1 filePaths, Boolean throwOnError, DbProviderManifest& providerManifest, DbProviderFactory& providerFactory, String& providerManifestToken, Memoizer`2& cachedCTypeFunction) 
    at System.Data.Metadata.Edm.StoreItemCollection..ctor(IEnumerable`1 xmlReaders) 
    at System.Data.Entity.Migrations.Extensions.XDocumentExtensions.GetStoreItemCollection(XDocument model, DbProviderInfo& providerInfo) 
    at System.Data.Entity.Migrations.Infrastructure.EdmModelDiffer.Diff(XDocument sourceModel, XDocument targetModel, String connectionString) 
    at System.Data.Entity.Migrations.DbMigrator.IsModelOutOfDate(XDocument model, DbMigration lastMigration) 
    at System.Data.Entity.Migrations.DbMigrator.Upgrade(IEnumerable`1 pendingMigrations, String targetMigrationId, String lastMigrationId) 
    at System.Data.Entity.Migrations.Infrastructure.MigratorLoggingDecorator.Upgrade(IEnumerable`1 pendingMigrations, String targetMigrationId, String lastMigrationId) 
    at System.Data.Entity.Migrations.DbMigrator.Update(String targetMigration) 
    at System.Data.Entity.Migrations.Infrastructure.MigratorBase.Update(String targetMigration) 
    at System.Data.Entity.Migrations.Design.ToolingFacade.UpdateRunner.RunCore() 
    at System.Data.Entity.Migrations.Design.ToolingFacade.BaseRunner.Run() 
Schema specified is not valid. Errors: 
(0,0) : warning 0005: Could not find schema information for the attribute 'Namespace'. 
(0,0) : warning 0005: Could not find schema information for the attribute 'Provider'. 
(0,0) : warning 0005: Could not find schema information for the attribute 'ProviderManifestToken'. 
(0,0) : warning 0005: Could not find schema information for the attribute 'Alias'. 
(0,0) : error 0010: The element Schema in namespace http://schemas.microsoft.com/ado/2009/11/edm/ssdl was unexpected for the root element. The expected Schema in one of the following namespaces: http://schemas.microsoft.com/ado/2006/04/edm/ssdl, http://schemas.microsoft.com/ado/2009/02/edm/ssdl. 

任何方式来获得通过这个虽然在.NET 4.0?我知道EF 5的某些功能在.Net 4上不可用。但我无法升级到.Net 4.5或VS 2012,因为我的SSD只有60GB,目前它只有4 GB的空闲空间,所以VS2012安装程序获胜不要让我安装(即使在其他驱动器上)。

Web.config中有参照此一:

<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" /> 
+0

该项目的web.config是什么样子的? – IronMan84

+0

此处的问题是,要加载的模型位于v3架构中,而.NET Framework 4中的EF组件只能理解v2架构。你是如何安装EF5的?什么是您使用的EntityFramework.dll的版本(我假设它是5.0.0.0,而.NET Framework 4上的EF5 EntityFramework.dll版本应该是4.4.0.0) – Pawel

+0

@Pawel:你说得对,它是4.4。我更新了这篇文章。我通过nuget安装它。此外,它会在第一次加载时抛出错误,如果我刷新页面,它会正常工作。但是当我再次刷新页面时,应用程序会永久挂起,我必须执行iisreset,然后循环再次重复:)。很烦人! – TCM

回答

1

看来,存储在数据库中的模型具有V3架构,而你使用的是.NET Framework 4的更新数据库。 .NET Framework 4中的EF组件不理解v3(仅v2)架构,因此错误。我相信你需要迁移到.NET Framework 4.5和VS2012。