C# 远程服务器上发生异常:表';db_a185f5_ems.tmpid实体_员工';不';不存在

C# 远程服务器上发生异常:表';db_a185f5_ems.tmpid实体_员工';不';不存在,c#,asp.net-mvc-5,C#,Asp.net Mvc 5,我知道这个问题已经被问了好几次了,但我已经研究了所有的解决方案,这些解决方案都没有回答我的问题。我面临的问题出现在远程服务器上。我在本地服务器上使用MVC5、EntityFramework6和MySQL 5.7,解决方案在本地服务器上运行时没有异常或错误。但当我将解决方案加载到远程服务器时,问题就出现了。这是个例外 Table 'db_a185f5_ems.tmpidentity_employee' doesn't exist Description: An unhandled excepti

我知道这个问题已经被问了好几次了,但我已经研究了所有的解决方案,这些解决方案都没有回答我的问题。我面临的问题出现在远程服务器上。我在本地服务器上使用MVC5、EntityFramework6和MySQL 5.7,解决方案在本地服务器上运行时没有异常或错误。但当我将解决方案加载到远程服务器时,问题就出现了。这是个例外

Table 'db_a185f5_ems.tmpidentity_employee' doesn't exist

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: MySql.Data.MySqlClient.MySqlException: Table 'db_a185f5_ems.tmpidentity_employee' doesn't exist

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:    

[MySqlException (0x80004005): Table 'db_a185f5_ems.tmpidentity_employee' doesn't exist]
   MySql.Data.MySqlClient.MySqlStream.ReadPacket() +306
   MySql.Data.MySqlClient.NativeDriver.GetResult(Int32& affectedRow, Int64& insertedId) +67
   MySql.Data.MySqlClient.Driver.GetResult(Int32 statementId, Int32& affectedRows, Int64& insertedId) +17
   MySql.Data.MySqlClient.Driver.NextResult(Int32 statementId, Boolean force) +110
   MySql.Data.MySqlClient.MySqlDataReader.NextResult() +772
   MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior) +1512
   MySql.Data.Entity.EFMySqlCommand.ExecuteDbDataReader(CommandBehavior behavior) +33
   System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior) +12
   System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.<Reader>b__c(DbCommand t, DbCommandInterceptionContext`1 c) +9
   System.Data.Entity.Infrastructure.Interception.InternalDispatcher`1.Dispatch(TTarget target, Func`3 operation, TInterceptionContext interceptionContext, Action`3 executing, Action`3 executed) +72
   System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.Reader(DbCommand command, DbCommandInterceptionContext interceptionContext) +355
   System.Data.Entity.Internal.InterceptableDbCommand.ExecuteDbDataReader(CommandBehavior behavior) +167
   System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior) +12
   System.Data.Entity.Core.Mapping.Update.Internal.DynamicUpdateCommand.Execute(Dictionary`2 identifierValues, List`1 generatedValues) +234
   System.Data.Entity.Core.Mapping.Update.Internal.UpdateTranslator.Update() +139

[UpdateException: An error occurred while updating the entries. See the inner exception for details.]
   System.Data.Entity.Core.Mapping.Update.Internal.UpdateTranslator.Update() +319
   System.Data.Entity.Core.EntityClient.Internal.EntityAdapter.<Update>b__2(UpdateTranslator ut) +9
   System.Data.Entity.Core.EntityClient.Internal.EntityAdapter.Update(T noChangesResult, Func`2 updateFunction) +120
   System.Data.Entity.Core.EntityClient.Internal.EntityAdapter.Update() +77
   System.Data.Entity.Core.Objects.ObjectContext.<SaveChangesToStore>b__35() +11
   System.Data.Entity.Core.Objects.ObjectContext.ExecuteInTransaction(Func`1 func, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction, Boolean releaseConnectionOnSuccess) +288
   System.Data.Entity.Core.Objects.ObjectContext.SaveChangesToStore(SaveOptions options, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction) +163
   System.Data.Entity.Core.Objects.<>c__DisplayClass2a.<SaveChangesInternal>b__27() +22
   System.Data.Entity.Infrastructure.DefaultExecutionStrategy.Execute(Func`1 operation) +9
   System.Data.Entity.Core.Objects.ObjectContext.SaveChangesInternal(SaveOptions options, Boolean executeInExistingTransaction) +222
   System.Data.Entity.Core.Objects.ObjectContext.SaveChanges(SaveOptions options) +7
   System.Data.Entity.Internal.InternalContext.SaveChanges() +114

[DbUpdateException: An error occurred while updating the entries. See the inner exception for details.]
   System.Data.Entity.Internal.InternalContext.SaveChanges() +199
   System.Data.Entity.Internal.LazyInternalContext.SaveChanges() +27
   System.Data.Entity.DbContext.SaveChanges() +20
   EMS.Controllers.<CreateEmployee>d__54.MoveNext() in c:\Users\Hira\Documents\Visual Studio 2013\Projects\EMS\EMS\Controllers\AdministratorController.cs:401
   System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +92
   System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +58
   System.Web.Mvc.Async.TaskAsyncActionDescriptor.EndExecute(IAsyncResult asyncResult) +97
   System.Web.Mvc.Async.<>c__DisplayClass37.<BeginInvokeAsynchronousActionMethod>b__36(IAsyncResult asyncResult) +17
   System.Web.Mvc.Async.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult) +10
   System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
   System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult) +32
   System.Web.Mvc.Async.AsyncInvocationWithFilters.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3d() +50
   System.Web.Mvc.Async.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f() +225
   System.Web.Mvc.Async.<>c__DisplayClass33.<BeginInvokeActionMethodWithFilters>b__32(IAsyncResult asyncResult) +10
   System.Web.Mvc.Async.WrappedAsyncResult`1.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.<BeginInvokeAction>b__1c() +26
   System.Web.Mvc.Async.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult asyncResult) +100
   System.Web.Mvc.Async.WrappedAsyncResult`1.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.<BeginExecuteCore>b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState) +13
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +29
   System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
   System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +36
   System.Web.Mvc.Controller.<BeginExecute>b__15(IAsyncResult asyncResult, Controller controller) +12
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +22
   System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
   System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +26
   System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult) +10
   System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__5(IAsyncResult asyncResult, ProcessRequestState innerState) +21
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +29
   System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
   System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +28
   System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +9744261
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155
我已经检查了远程服务器上的表。他们都是Innodb。没有包含“tmpidentity”的表,因为我没有使用它创建任何表。我使用了代码优先的方法。远程服务器正在使用phpMyAdmin

这是我的DbContext:

public class EMSDbContext : DbContext
{

    public static EMSDbContext Create()
    {
        return new EMSDbContext();
    }
    public DbSet<Administrator> Administrators { get; set; }
    public DbSet<Employee> Employees { get; set; }
    public DbSet<Client> Clients { get; set; }

    protected override void OnModelCreating(DbModelBuilder modelBuilder)
    {
      modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();           
      modelBuilder.Conventions.Remove<ForeignKeyIndexConvention>(); 
    }
}
公共类EMSDbContext:DbContext
{
公共静态EMSDbContext Create()
{
返回新的EMSDbContext();
}
公共数据库集管理员{get;set;}
公共数据库集雇员{get;set;}
公共数据库集客户端{get;set;}
模型创建时受保护的覆盖无效(DbModelBuilder modelBuilder)
{
modelBuilder.Conventions.Remove();
modelBuilder.Conventions.Remove();
}
}

更新

我已经将主键从Guid改为int,我不知道它是如何工作的。 这是我以前的模特

 public class Employee
{       
    [Key]
    [Required]
    [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
    public Guid EmployeeId { get; set; }

    public string FirstName { get; set; }      
    public string LastName { get; set; }
    public string Email { get; set; }
    public DateTime JoiningDate { get; set; }
    public string Username { get; set; }
    public string Password { get; set; }    
}
我刚把PK改成int类型

 public class Employee
{       
    [Key]
    [Required]       
    public int EmployeeId { get; set; }

    public string FirstName { get; set; }      
    public string LastName { get; set; }
    public string Email { get; set; }
    public DateTime JoiningDate { get; set; }
    public string Username { get; set; }
    public string Password { get; set; }    
}
有人能解释一下吗。从这看来,我必须改变整个代码的pk类型。Guid类型是否与远程服务器有关


PS:我正在使用基于Windows的远程服务器平台。

我知道这次重播对您来说太晚了。这是给别人的。 我今天收到了同样的问题。我也不知道这个错误。在这之后,我了解了自动生成的guid是在mysql中使用触发器维护的。由MySql连接器生成的触发器。我错过了。我从另一个表复制粘贴触发器。我的问题已经解决了


详细信息如下

首先运行
显示引擎
命令以确保InnoDB存在。如何导入所需的表(直接复制到远程服务器或使用通过SQL查询文件导入)?尝试复制
ib_logfile*
ibdata
(MySQL根数据目录中的所有
ib*
文件)文件。Show Engine将InnoDB显示为引擎。我已经从mysql工作台导入了一个转储文件,并通过ftp传输。远程服务器正在使用phpMyAdmin。我无权访问托管域上服务器的根目录。如何添加这些文件。请提供帮助。如果生产服务器操作系统是Unix系列,并且您已使用
mysqldump
导入表,请确保EF上声明的所有标识符都遵循生产服务器上的区分大小写规则。有关详细信息,请参阅。感谢您的回复。我希望这对其他人有帮助(y)
 public class Employee
{       
    [Key]
    [Required]       
    public int EmployeeId { get; set; }

    public string FirstName { get; set; }      
    public string LastName { get; set; }
    public string Email { get; set; }
    public DateTime JoiningDate { get; set; }
    public string Username { get; set; }
    public string Password { get; set; }    
}