我一直在使用 EF6 在 VS2013 中开发 MVC5 应用程序。我在开发环境中没有遇到任何问题,但是在发布到 Win 2012 IIS 服务器并运行应用程序时,我遇到了许多页面错误。
我面临的错误似乎在所有页面中都是一致的。
“属性‘CountFrequency’不是字符串或字节数组。只能为字符串和字节数组属性配置长度。”
第 35 行:第 36 行:第 37 行:@foreach(模型中的变量项) 第 38 行:{ 第 39 行:
这是堆栈跟踪:
*
[InvalidOperationException: The property 'CountFrequency' is not a String or Byte array. Length can only be configured for String and Byte array properties.]
System.Data.Entity.ModelConfiguration.Configuration.ConventionPrimitivePropertyConfiguration.HasMaxLength(Int32 maxLength) +612
System.Data.Entity.ModelConfiguration.Conventions.PrimitivePropertyAttributeConfigurationConvention`1.<.ctor>b__1(ConventionPrimitivePropertyConfiguration configuration, IEnumerable`1 attributes) +114
System.Data.Entity.ModelConfiguration.Configuration.PropertyConfigurationConventionDispatcher.Dispatch() +38
System.Data.Entity.ModelConfiguration.Configuration.ConventionsConfiguration.ApplyPropertyConfiguration(PropertyInfo propertyInfo, Func`1 propertyConfiguration, ModelConfiguration modelConfiguration) +176
System.Data.Entity.ModelConfiguration.Configuration.ConventionsConfiguration.ApplyPropertyConfiguration(PropertyInfo propertyInfo, Func`1 propertyConfiguration, ModelConfiguration modelConfiguration) +218
System.Data.Entity.ModelConfiguration.Mappers.PropertyMapper.MapPrimitiveOrComplexOrEnumProperty(PropertyInfo propertyInfo, Func`1 structuralTypeConfiguration, Boolean discoverComplexTypes) +650
System.Data.Entity.ModelConfiguration.Mappers.<>c__DisplayClass14.<MapEntityType>b__e(PropertyMapper m, PropertyInfo p) +46
System.Data.Entity.ModelConfiguration.Mappers.TypeMapper.MapStructuralElements(Type type, ICollection`1 annotations, Action`2 propertyMappingAction, Boolean mapDeclaredPropertiesOnly, Func`1 structuralTypeConfiguration) +516
System.Data.Entity.ModelConfiguration.Mappers.TypeMapper.MapEntityType(Type type) +876
System.Data.Entity.<>c__DisplayClassd.<MapTypes>b__7(Type type) +16
System.Linq.WhereListIterator`1.MoveNext() +165
System.Data.Entity.Utilities.IEnumerableExtensions.Each(IEnumerable`1 ts, Action`1 action) +168
System.Data.Entity.DbModelBuilder.MapTypes(EdmModel model) +428
System.Data.Entity.DbModelBuilder.Build(DbProviderManifest providerManifest, DbProviderInfo providerInfo) +281
System.Data.Entity.DbModelBuilder.Build(DbConnection providerConnection) +288
System.Data.Entity.Internal.LazyInternalContext.CreateModel(LazyInternalContext internalContext) +94
System.Data.Entity.Internal.RetryLazy`2.GetValue(TInput input) +248
System.Data.Entity.Internal.LazyInternalContext.InitializeContext() +618
System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType) +26
System.Data.Entity.Internal.Linq.InternalSet`1.Initialize() +72
System.Data.Entity.Internal.Linq.InternalSet`1.GetEnumerator() +21
ASP._Page_Views_Logic_List_cshtml.Execute() in c:\inetpub\Internal\KSCycleCounts\Views\Logic\List.cshtml:37
System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +280
System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +125
System.Web.WebPages.StartPage.ExecutePageHierarchy() +143
System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +110
System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +380
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +109
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +890
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +97
System.Web.Mvc.Async.<>c__DisplayClass1e.<BeginInvokeAction>b__1b(IAsyncResult asyncResult) +241
System.Web.Mvc.Controller.<BeginExecuteCore>b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState) +29
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +111
System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +53
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +19
System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__4(IAsyncResult asyncResult, ProcessRequestState innerState) +51
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +111
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +606
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +288
*
我知道我的连接字符串是有效的并且正在工作。在 Windows 2012 中,我安装了所有角色(ASP.NET 4.5 和 .NET 4.5)。在 IIS 中,我已将我的应用程序池配置为使用 .NET 4,并使用管理员帐户作为测试身份。
谢谢!