我是编程新手,所以请耐心问一个问题
我在Visual Studio 2013中创建了一个C#项目,它在localhost上工作正常,我使用代码优先方法创建我的数据库并在包管理器控制台中使用update-database
(并且它已成功完成) ,表是在本地服务器上创建的,插入值没有错误,但是当我尝试将该数据库复制到我的Web服务器时,问题就开始出现了(我正在使用[bigrock] [1]提供的窗口托管,我提到了我用来将本地服务器数据库复制到托管服务器的步骤。
web.config
。enable-migrations
后跟update-migrations
。这就是我收到错误列名无效的地方' xyz'。我当时忽略了这些错误,但当我尝试运行我的网站并尝试注册第一个用户时,我得到了同样的错误,不知道这些错误来自哪里
这是我在服务器上获得的(整个堆栈跟踪):
列名称无效' RegisteredDate'。
列名称无效'名称'。
列名称无效'移动'。
列名称无效'电子邮件'。描述:执行当前Web请求期间发生了未处理的异常。请查看堆栈跟踪以获取有关错误及其源自代码的位置的更多信息。
异常详细信息:System.Data.SqlClient.SqlException:列名无效' RegisteredDate'。
列名称无效'名称'。
列名称无效'移动'。
列名称无效'电子邮件'。来源错误:
在执行当前Web请求期间生成了未处理的异常。可以使用下面的异常堆栈跟踪来识别有关异常的起源和位置的信息。
堆栈追踪:
[SqlException(0x80131904):列名无效' RegisteredDate'。 列名称无效'名称'。 列名称无效'移动'。 列名称无效'电子邮件'。] System.Data.SqlClient.SqlConnection.OnError(SqlException异常,Boolean breakConnection,Action
1 wrapCloseInAction) +1789270 System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action
1 wrapCloseInAction)+5340622 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.SqlCommand.FinishExecuteReader(SqlDataReader ds,RunBehavior runBehavior,String resetOptionsString)+275 System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior,RunBehavior runBehavior,Boolean returnStream,Boolean async,Int32 timeout,Task& task,Boolean asyncWrite,SqlDataReader ds)+1421 System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior,RunBehavior runBehavior,Boolean returnStream,String method,TaskCompletionSource1 completion, Int32 timeout, Task& task, Boolean asyncWrite) +177 System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource
1 completion,String methodName,Boolean sendToPipe,Int32 timeout,Boolean asyncWrite)+208 System.Data.SqlClient.SqlCommand.ExecuteNonQuery()+ 163 WebMatrix.Data.Database.Execute(String commandText,Object [] args)+111 WebMatrix.WebData.DatabaseWrapper.Execute(String commandText,Object []参数)+14 WebMatrix.WebData.SimpleMembershipProvider.CreateUserRow(IDatabase db,String userName,IDictionary2 values) +671 WebMatrix.WebData.SimpleMembershipProvider.CreateUserAndAccount(String userName, String password, Boolean requireConfirmation, IDictionary
2个值)+65 WebMatrix.WebData.WebSecurity.CreateUserAndAccount(String userName,String password,Object propertyValues,Boolean requireConfirmationToken)+134 Riduk.Areas.Mobile.Controllers.AppStartController.Register(UserProfile model,String Password)+191 lambda_method(Closure,ControllerBase,Object [])+147 System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller,Object []参数)+14 System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext,IDictionary2 parameters) +156 System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary
2个参数)+27 System.Web.Mvc.Async.AsyncControllerActionInvoker.b__39(IAsyncResult asyncResult,ActionInvocation innerInvokeState)+22 System.Web.Mvc.Async.WrappedAsyncResult2.CallEndDelegate(IAsyncResult asyncResult) +29 System.Web.Mvc.Async.WrappedAsyncResultBase
1.End()+49 System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult)+34 System.Web.Mvc.Async.AsyncInvocationWithFilters.b__3d()+50 System.Web.Mvc.Async。<> c__DisplayClass46.b__3f()+225 System.Web.Mvc.Async。<> c__DisplayClass33.b__32(IAsyncResult asyncResult)+10 System.Web.Mvc.Async.WrappedAsyncResult1.CallEndDelegate(IAsyncResult asyncResult) +10 System.Web.Mvc.Async.WrappedAsyncResultBase
1.End()+49 System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult)+34 System.Web.Mvc.Async。<> c__DisplayClass2b.b__1c()+26 System.Web.Mvc.Async。<> c__DisplayClass21.b__1e(IAsyncResult asyncResult)+100 System.Web.Mvc.Async.WrappedAsyncResult1.CallEndDelegate(IAsyncResult asyncResult) +10 System.Web.Mvc.Async.WrappedAsyncResultBase
1.End()+49 System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult)+27 System.Web.Mvc.Controller.b__1d(IAsyncResult asyncResult,ExecuteCoreState innerState)+13 System.Web.Mvc.Async.WrappedAsyncVoid1.CallEndDelegate(IAsyncResult asyncResult) +36 System.Web.Mvc.Async.WrappedAsyncResultBase
1.End()+54 System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult)+41 System.Web.Mvc.Controller.b__15(IAsyncResult asyncResult,Controller controller)+12 System.Web.Mvc.Async.WrappedAsyncVoid1.CallEndDelegate(IAsyncResult asyncResult) +28 System.Web.Mvc.Async.WrappedAsyncResultBase
1.End()+54 System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult)+31 System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult)+10 System.Web.Mvc.MvcHandler.b__5(IAsyncResult asyncResult,ProcessRequestState innerState)+21 System.Web.Mvc.Async.WrappedAsyncVoid1.CallEndDelegate(IAsyncResult asyncResult) +36 System.Web.Mvc.Async.WrappedAsyncResultBase
1.End()+54 System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult)+31 System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result)+9 System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()+9690164 System.Web.HttpApplication.ExecuteStep(IExecutionStep step,Boolean& completedSynchronously)+155
这是我在包管理器控制台
中使用update-database
的过程
没有待定的显式迁移。
运行种子方法。
System.Data.SqlClient.SqlException(0x80131904):列名无效' RegisteredDate'。
列名称无效' DOB'。
列名称无效'电子邮件'。
列名称无效'名称'。at System.Data.SqlClient.SqlConnection.OnError(SqlException异常,Boolean breakConnection,Action
1 wrapCloseInAction)
1 wrapCloseInAction) 在System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj,Boolean callerHasConnectionLock,Boolean asyncClose) 在System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior,SqlCommand cmdHandler,SqlDataReader dataStream,BulkCopySimpleResultSet bulkCopyHandler,TdsParserStateObject stateObj,Boolean& dataReady) 在System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds,RunBehavior runBehavior,String resetOptionsString) 在System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior,RunBehavior runBehavior,Boolean returnStream,Boolean async,Int32 timeout,Task& task,Boolean asyncWrite,SqlDataReader ds) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior,RunBehavior runBehavior,Boolean returnStream,String method,TaskCompletionSource
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action1 completion, Int32 timeout, Task& task, Boolean asyncWrite) at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource
1 completion,String methodName,Boolean sendToPipe,Int32 timeout,Boolean asyncWrite) 在System.Data.SqlClient.SqlCommand.ExecuteNonQuery() at WebMatrix.Data.Database.Execute(String commandText,Object [] args) at WebMatrix.WebData.DatabaseWrapper.Execute(String commandText,Object [] parameters) at WebMatrix.WebData.SimpleMembershipProvider.CreateUserRow(IDatabase db,String userName,IDictionary2 values) at WebMatrix.WebData.SimpleMembershipProvider.CreateUserAndAccount(String userName, String password, Boolean requireConfirmation, IDictionary
2个值) at WebMatrix.WebData.WebSecurity.CreateUserAndAccount(String userName,String password,Object propertyValues,Boolean requireConfirmationToken) at c:\ Users \ Me \ Desktop \ Project \ MyProject \ MyProject \ Migrations \ Configuration.cs中的MyProject.Migrations.Configuration.SeedMembership():第62行 at c:\ Users \ Me \ Desktop \ Project \ MyProject \ MyProject \ Migrations \ Configuration.cs中的MyProject.Migrations.Configuration.Seed(UsersContext context):第31行 在System.Data.Entity.Migrations.DbMigrationsConfiguration1.OnSeed(DbContext context) at System.Data.Entity.Migrations.DbMigrator.SeedDatabase() at System.Data.Entity.Migrations.Infrastructure.MigratorLoggingDecorator.SeedDatabase() at System.Data.Entity.Migrations.DbMigrator.Upgrade(IEnumerable
1 pendingMigrations,String targetMigrationId,String lastMigrationId) 在System.Data.Entity.Migrations.Infrastructure.MigratorLoggingDecorator.Upgrade(IEnumerable`1 pendingMigrations,String targetMigrationId,String lastMigrationId) 在System.Data.Entity.Migrations.DbMigrator.UpdateInternal(String targetMigration) 在System.Data.Entity.Migrations.DbMigrator。<> c__DisplayClassc.b__b() 在System.Data.Entity.Migrations.DbMigrator.EnsureDatabaseExists(Action mustSucceedToKeepDatabase) 在System.Data.Entity.Migrations.Infrastructure.MigratorBase.EnsureDatabaseExists(Action mustSucceedToKeepDatabase) 在System.Data.Entity.Migrations.DbMigrator.Update(String targetMigration) 在System.Data.Entity.Migrations.Infrastructure.MigratorBase.Update(String targetMigration) 在System.Data.Entity.Migrations.Design.ToolingFacade.UpdateRunner.Run() 在System.AppDomain.DoCallBack(CrossAppDomainDelegate callBackDelegate) 在System.AppDomain.DoCallBack(CrossAppDomainDelegate callBackDelegate) 在System.Data.Entity.Migrations.Design.ToolingFacade.Run(BaseRunner runner) 在System.Data.Entity.Migrations.Design.ToolingFacade.Update(String targetMigration,Boolean force) 在System.Data.Entity.Migrations.UpdateDatabaseCommand。<> c__DisplayClass2。< .ctor> b__0() 在System.Data.Entity.Migrations.MigrationsDomainCommand.Execute(Action命令) ClientConnectionId:1f5ed896-956b-43dd-a08c-ff86b144021f 错误号码:207,状态:1,等级:16 列名称无效' RegisteredDate'。 列名称无效' DOB'。 列名称无效'电子邮件'。 列名称无效'名称'。
以下是web.config
的连接字符串:
<connectionStrings>
<add name="DefaultConnection"
connectionString="Data Source=103.xx.xx.xx2;Integrated Security=False;User ID=MyDatabase;Password=MyPassWord;Connect Timeout=15;Encrypt=False;Packet Size=4096"
providerName="System.Data.SqlClient" />
</connectionStrings>
我希望这可能足以让你们帮助一个人,
***编辑 - 删除我的模型和架构以保护隐私
答案 0 :(得分:0)
我无法解决我的问题,但在与bigrock支持人员聊天时找到了解决方法,我采取了以下步骤来解决我的问题: -
**注意 - 仍在寻找先前方法中的错误原因