列名无效。不知道为什么?

问题描述 投票:0回答:2

最近我将DateofBirth添加到表中。在本地,它的工作正常。我还更新了客户端的数据库和实体数据模型。但是出现了错误。

列名称“DateofBirth”无效。描述:执行当前Web请求期间发生未处理的异常。请查看堆栈跟踪以获取有关错误及其源自代码的位置的更多信息。

异常详细信息:System.Data.SqlClient.SqlException:无效的列名称'DateofBirth'。

堆栈跟踪:

[SqlException(0x80131904):无效的列名'DateofBirth'。] System.Data.SqlClient.SqlConnection.OnError(SqlException异常,Boolean breakConnection,Action1 wrapCloseInAction) +3305692 System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) +736 System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady) +4061 System.Data.SqlClient.SqlDataReader.TryConsumeMetaData() +90 System.Data.SqlClient.SqlDataReader.get_MetaData() +99 System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString, Boolean isInternal, Boolean forDescribeParameterEncryption, Boolean shouldCacheForAlwaysEncrypted) +604 System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, Boolean inRetry, SqlDataReader ds, Boolean describeParameterEncryptionRequest) +3303 System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource1完成,Int32超时,Task&task,Boolean&usedCache,Boolean asyncWrite,Boolean inRetry)+667 System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior,RunBehavior runBehavior,Boolean returnStream,String method)+83 System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior,String method)+301 System.Data.Entity.Infrastructure。 Interception.InternalDispatcher1.Dispatch(TTarget target, Func3操作,TInterceptionContext interceptionContext,Action3 executing, Action3执行)+104 System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.Reader(DbCommand命令,DbCommandInterceptionContext interceptionContext)+499 System.Data.Entity.Core.EntityClient.Internal.EntityCommandDefinition.ExecuteStoreCommands (EntityCommand entityCommand,CommandBehavior行为)+36

[EntityCommandExecutionException:执行命令定义时发生错误。有关详细信息,请参阅内部异常。] System.Data.Entity.Core.EntityClient.Internal.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand entityCommand,CommandBehavior behavior)+125 System.Data.Entity.Core.Objects.Internal.ObjectQueryExecutionPlan.Execute(ObjectContext context ,ObjectParameterCollection parameterValues)+1014 System.Data.Entity.Core.Objects.ObjectContext.ExecuteInTransaction(Func1 func, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction, Boolean releaseConnectionOnSuccess) +459 System.Data.Entity.Core.Objects.<>c__DisplayClass7.<GetResults>b__5() +203 System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute(Func1 operation)+234 System.Data.Entity.Core.Objects.ObjectQuery1.GetResults(Nullable1 forMergeOption)+354 System.Data.Entity.Core.Objects。 ObjectQuery1.<System.Collections.Generic.IEnumerable<T>.GetEnumerator>b__0() +30 System.Data.Entity.Internal.LazyEnumerator1.MoveNext()+39 System.Collections.Generic.List1..ctor(IEnumerable1 collection)+436 System.Linq.Enumerable.ToList(IEnumerable1 source) +70 BLAST.Controllers.EmployeeVarityReportController.EmpDetails() +5302 lambda_method(Closure , ControllerBase , Object[] ) +87 System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary2 parameters)+229 System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext,ActionDescriptor actionDescriptor,IDictionary2 parameters) +35 System.Web.Mvc.Async.AsyncControllerActionInvoker.<BeginInvokeSynchronousActionMethod>b__39(IAsyncResult asyncResult, ActionInvocation innerInvokeState) +39 System.Web.Mvc.Async.WrappedAsyncResult2.CallEndDelegate (IAsyncResult asyncResult)+77 System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult) +42 System.Web.Mvc.Async.AsyncInvocationWithFilters.b__3d()+72 System.Web.Mvc.Async。<> c__DisplayClass46.b__3f()+387 System.Web.Mvc.Async。<> c__DisplayClass46.b__3f()+ 387 System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult)+42 System.Web.Mvc.Async。<> c__DisplayClass2b.b__1c()+38 System.Web.Mvc.Async。<> c__DisplayClass21.b__1e(IAsyncResult) asyncResult)+188 System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult)+38 System.Web.Mvc.Controller.b__1d(IAsyncResult asyncResult,ExecuteCoreState innerState)+29 System.Web.Mvc.Async.WrappedAsyncVoid1.CallEndDelegate(IAsyncResult asyncResult) +73 System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +52 System.Web.Mvc.Async.WrappedAsyncVoid1.CallEndDelegate (IAsyncResult asyncResult)+39 System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult)+38 System.Web.Mvc.MvcHandler.b__5(IAsyncResult asyncResult,ProcessRequestState innerState)+43 System.Web.Mvc.Async.WrappedAsyncVoid`1 .CallEndDelegate(IAsyncResult asyncResult)+73 System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult) asyncResult)+38 System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()+602 System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step)+195 System.Web.HttpApplication.ExecuteStep(IExecutionStep step,Boolean&completedSynchronously) +128

asp.net-mvc entity-framework client-server stack-trace
2个回答
2
投票

该列不存在于表中,您必须运行迁移或使用其他方法更新客户数据库


1
投票

基于堆栈跟踪,我怀疑您已在配置类中将AutomaticMigrationsEnabled设置为false。要解决此问题,您需要手动创建新的迁移文件。您可以在Nuget包管理器控制台中创建运行Add-Migration命令的新迁移。

Here is a tutorial on how to create a new migration script.

© www.soinside.com 2019 - 2024. All rights reserved.