列名称'Discriminator'无效

时间:2015-04-21 16:28:51

标签: asp.net-mvc

我有一个使用ASP NET MVC 5数据库来验证用户的现有AppUsers。它已经工作了一年多。

今天,我创建了一个新的演示ASP MVC 5应用程序,并将[Authorize]标记设置为特定的[AspNetRoles]角色。我还在新应用程序connectionString文件中设置了“AppUsers”web.config。它与第一个现有应用程序的连接相同

当我尝试使用新应用程序登录时,我收到如下所示的错误。我假设我可以使用“AppUsers”DB来验证使用不同应用程序的用户。任何关于如何解决这个问题的建议将不胜感激。我搜索了网络,但这个错误似乎有很多不同的原因,我所看到的似乎都没有解释我的问题。

谢谢 麦克

  

无效的列名称'Discriminator'。       描述:执行当前Web请求期间发生未处理的异常。请查看堆栈跟踪了解更多信息   有关错误的信息以及它在代码中的起源。

Exception Details: System.Data.SqlClient.SqlException: Invalid column name 'Discriminator'.

Source Error:


Line 46:             if (ModelState.IsValid)
Line 47:             {
Line 48:                 var user = await UserManager.FindAsync(model.UserName, model.Password);
Line 49:                 if (user != null)
Line 50:                 {


Source File: c:\Users\204026705\Documents\MyApps\!!!!VSnet\TestPublishToNewServer\TestPublishToNewServer\Controllers\AccountController.cs
     

行:48

Stack Trace:


[SqlException (0x80131904): Invalid column name 'Discriminator'.]
   System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
     

1767866          System.Data.SqlClient.SqlInternalConnection.OnError(SQLEXCEPTION   exception,Boolean breakConnection,Action 1 wrapCloseInAction) +5352418 System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) +244 System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady) +1691 System.Data.SqlClient.SqlDataReader.TryConsumeMetaData() +61 System.Data.SqlClient.SqlDataReader.get_MetaData() +90 System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) +365 System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, SqlDataReader ds) +1406 System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource 1 completion,Int32 timeout,Task&任务,   Boolean asyncWrite)+177          System.Data.SqlClient.SqlCommand.RunExecuteReader(的CommandBehavior   cmdBehavior,RunBehavior runBehavior,Boolean returnStream,String   方法)+53          System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior,String method)+134          System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(的CommandBehavior   行为)+41          System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior)+10          System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.b__c(的DbCommand   t,DbCommandInterceptionContext 1 c) +66 System.Data.Entity.Infrastructure.Interception.InternalDispatcher 1.Dispatch(TTarget   target,Func 3 operation, TInterceptionContext interceptionContext, Action 3执行,Action`3执行)+138          System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.Reader(的DbCommand   command,DbCommandInterceptionContext interceptionContext)+475          System.Data.Entity.Internal.InterceptableDbCommand.ExecuteDbDataReader(的CommandBehavior   行为)+239          System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior)+10          System.Data.Entity.Core.EntityClient.Internal.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand   entityCommand,CommandBehavior行为)+97

[EntityCommandExecutionException: An error occurred while executing the command definition. See the inner exception for
     

的信息。]          System.Data.Entity.Core.EntityClient.Internal.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand   entityCommand,CommandBehavior行为)+181          System.Data.Entity.Core.Objects.Internal.ObjectQueryExecutionPlan.Execute(ObjectContext的   context,ObjectParameterCollection parameterValues)+1282          System.Data.Entity.Core.Objects&LT;&GT; c__DisplayClass7.b__6()   184          System.Data.Entity.Core.Objects.ObjectContext.ExecuteInTransaction(Func键1 func, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction, Boolean releaseConnectionOnSuccess) +448 System.Data.Entity.Core.Objects.<>c__DisplayClass7.<GetResults>b__5() +270 System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute(Func 1   操作)+251          System.Data.Entity.Core.Objects.ObjectQuery 1.GetResults(Nullable 1   forMergeOption)+645          System.Data.Entity.Core.Objects.ObjectQuery 1.<System.Collections.Generic.IEnumerable<T>.GetEnumerator>b__0() +68 System.Data.Entity.Internal.LazyEnumerator 1.MoveNext()+68          System.Linq.Enumerable.FirstOrDefault(IEnumerable的1 source) +164 System.Data.Entity.Core.Objects.ELinq.ObjectQueryProvider.<GetElementFunction>b__1(IEnumerable 1   序列)+83          System.Data.Entity.Core.Objects.ELinq.ObjectQueryProvider.ExecuteSingle(IEnumerable 1 query, Expression queryRoot) +107 System.Data.Entity.Core.Objects.ELinq.ObjectQueryProvider.System.Linq.IQueryProvider.Execute(Expression expression) +197 System.Data.Entity.Internal.Linq.DbQueryProvider.Execute(Expression expression) +155 System.Linq.Queryable.FirstOrDefault(IQueryable 1 source)+251          Microsoft.AspNet.Identity.EntityFramework.UserStore 1.FindByNameAsync(String userName) +1175 Microsoft.AspNet.Identity.<FindByNameAsync>d__d.MoveNext() +231 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +93 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +52 System.Runtime.CompilerServices.TaskAwaiter 1.GetResult()+24          Microsoft.AspNet.Identity.d__15.MoveNext()+ 540          System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务   任务)+93          System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务   任务)+52          System.Runtime.CompilerServices.TaskAwaiter 1.GetResult() +24 TestPublishToNewServer.Controllers.<Login>d__2.MoveNext() in c:\Users\204026705\Documents\MyApps\!!!!VSnet\TestPublishToNewServer\TestPublishToNewServer\Controllers\AccountController.cs:48 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +93 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +52 System.Runtime.CompilerServices.TaskAwaiter.GetResult() +21 lambda_method(Closure , Task ) +64 System.Threading.Tasks.TaskHelpersExtensions.ThrowIfFaulted(Task task) +64 System.Web.Mvc.Async.TaskAsyncActionDescriptor.EndExecute(IAsyncResult asyncResult) +114 System.Web.Mvc.Async.<>c__DisplayClass34.<BeginInvokeAsynchronousActionMethod>b__33(IAsyncResult asyncResult) +65 System.Web.Mvc.Async.WrappedAsyncResult 1.CallEndDelegate(IAsyncResult的   asyncResult)+47          System.Web.Mvc.Async.WrappedAsyncResultBase 1.End() +136 System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +102 System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult) +49 System.Web.Mvc.Async.AsyncInvocationWithFilters.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3c() +117 System.Web.Mvc.Async.<>c__DisplayClass45.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3e() +323 System.Web.Mvc.Async.<>c__DisplayClass30.<BeginInvokeActionMethodWithFilters>b__2f(IAsyncResult asyncResult) +44 System.Web.Mvc.Async.WrappedAsyncResult 1.CallEndDelegate(IAsyncResult的   asyncResult)+47          System.Web.Mvc.Async.WrappedAsyncResultBase 1.End() +136 System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +102 System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult) +50 System.Web.Mvc.Async.<>c__DisplayClass28.<BeginInvokeAction>b__19() +72 System.Web.Mvc.Async.<>c__DisplayClass1e.<BeginInvokeAction>b__1b(IAsyncResult asyncResult) +185 System.Web.Mvc.Async.WrappedAsyncResult 1.CallEndDelegate(IAsyncResult的   asyncResult)+42          System.Web.Mvc.Async.WrappedAsyncResultBase 1.End() +133 System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +56 System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +40 System.Web.Mvc.Controller.<BeginExecuteCore>b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState) +34 System.Web.Mvc.Async.WrappedAsyncVoid 1.CallEndDelegate(IAsyncResult的   asyncResult)+70          System.Web.Mvc.Async.WrappedAsyncResultBase 1.End() +139 System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +59 System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +40 System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +44 System.Web.Mvc.Controller.<BeginExecute>b__15(IAsyncResult asyncResult, Controller controller) +39 System.Web.Mvc.Async.WrappedAsyncVoid 1.CallEndDelegate(IAsyncResult的   asyncResult)+62          System.Web.Mvc.Async.WrappedAsyncResultBase 1.End() +139 System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +59 System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +40 System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +39 System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult) +39 System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__4(IAsyncResult asyncResult, ProcessRequestState innerState) +39 System.Web.Mvc.Async.WrappedAsyncVoid 1.CallEndDelegate(IAsyncResult的   asyncResult)+70          System.Web.Mvc.Async.WrappedAsyncResultBase`1.End()+139          System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult,Object tag)+59          System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult,Object tag)+40          System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult)+40          System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult的   结果)+38          System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()   9514928          System.Web.HttpApplication.ExecuteStep(IExecutionStep step,Boolean&amp; completedSynchronously)+155

1 个答案:

答案 0 :(得分:0)

解决方案是对所有nuget包进行全面更新。在我的例子中,我创建了新项目,从nuget更新了EF,实现了连接字符串更改以使用“AppUsers”DB来设置授权以对用户进行身份验证。

这让我陷入了主题错误。

Alundra建议迁移。但是,我过去已经完成了迁移。下一个合乎逻辑的步骤是更新nuget包。这解决了这个问题。我怀疑罪魁祸首只是在开始时才更新EF。

感谢 麦克