环境:asp.net mvc .net4.5
EF code first 程序部署到阿里云虚机上出错,本机上是没有问题的,错误提示:“无法检查模型兼容性,因为数据库不包含模型元数据。只能检查使用 Code First 或 Code First 迁移创建的数据库的模型兼容性。”
具体错误如下:
This XML file does not appear to have any style information associated with it. The document tree is shown below.
出现错误。
“ObjectContent1”类型未能序列化内容类型“application/xml; charset=utf-8”的响应正文。
1.InitializeDatabase(TContext context) 在 System.Data.Entity.Internal.InternalContext.<>c__DisplayClassf
</ExceptionMessage>
<ExceptionType>System.InvalidOperationException</ExceptionType>
<StackTrace/>
<InnerException>
<Message>出现错误。</Message>
<ExceptionMessage>
无法检查模型兼容性,因为数据库不包含模型元数据。只能检查使用 Code First 或 Code First 迁移创建的数据库的模型兼容性。
</ExceptionMessage>
<ExceptionType>System.NotSupportedException</ExceptionType>
<StackTrace>
在 System.Data.Entity.Internal.ModelCompatibilityChecker.CompatibleWithModel(InternalContext internalContext, ModelHashCalculator modelHashCalculator, Boolean throwIfNoMetadata, DatabaseExistenceState existenceState) 在 System.Data.Entity.Internal.InternalContext.CompatibleWithModel(Boolean throwIfNoMetadata, DatabaseExistenceState existenceState) 在 System.Data.Entity.DropCreateDatabaseIfModelChanges1.<CreateInitializationAction>b__e() 在 System.Data.Entity.Internal.InternalContext.PerformInitializationAction(Action action) 在 System.Data.Entity.Internal.InternalContext.PerformDatabaseInitialization() 在 System.Data.Entity.Internal.LazyInternalContext.<InitializeDatabase>b__4(InternalContext c) 在 System.Data.Entity.Internal.RetryAction
1.PerformAction(TInput input) 在 System.Data.Entity.Internal.LazyInternalContext.InitializeDatabaseAction(Action1 action) 在 System.Data.Entity.Internal.LazyInternalContext.InitializeDatabase() 在 System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType) 在 System.Data.Entity.Internal.Linq.InternalSet
1.Initialize() 在 System.Data.Entity.Internal.Linq.InternalSet1.GetEnumerator() 在 System.Data.Entity.Infrastructure.DbQuery
1.System.Collections.Generic.IEnumerable.GetEnumerator() 在 WriteArrayOfHouseToXml(XmlWriterDelegator , Object , XmlObjectSerializerWriteContext , CollectionDataContract ) 在 System.Runtime.Serialization.CollectionDataContract.WriteXmlValue(XmlWriterDelegator xmlWriter, Object obj, XmlObjectSerializerWriteContext context) 在 System.Runtime.Serialization.XmlObjectSerializerWriteContext.WriteDataContractValue(DataContract dataContract, XmlWriterDelegator xmlWriter, Object obj, RuntimeTypeHandle declaredTypeHandle) 在 System.Runtime.Serialization.XmlObjectSerializerWriteContext.SerializeWithoutXsiType(DataContract dataContract, XmlWriterDelegator xmlWriter, Object obj, RuntimeTypeHandle declaredTypeHandle) 在 System.Runtime.Serialization.DataContractSerializer.InternalWriteObjectContent(XmlWriterDelegator writer, Object graph, DataContractResolver dataContractResolver) 在 System.Runtime.Serialization.DataContractSerializer.InternalWriteObject(XmlWriterDelegator writer, Object graph, DataContractResolver dataContractResolver) 在 System.Runtime.Serialization.XmlObjectSerializer.WriteObjectHandleExceptions(XmlWriterDelegator writer, Object graph, DataContractResolver dataContractResolver) 在 System.Runtime.Serialization.DataContractSerializer.WriteObject(XmlWriter writer, Object graph) 在 System.Net.Http.Formatting.XmlMediaTypeFormatter.WriteToStream(Type type, Object value, Stream writeStream, HttpContent content) 在 System.Net.Http.Formatting.XmlMediaTypeFormatter.WriteToStreamAsync(Type type, Object value, Stream writeStream, HttpContent content, TransportContext transportContext, CancellationToken cancellationToken) --- End of stack trace from previous location where exception was thrown --- 在 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) 在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 在 System.Web.Http.WebHost.HttpControllerHandler.d__1b.MoveNext()
错误地址:wwww.iflve.com/api/houses
换ecs