【问题标题】:Problem deploying ASP.NET CORE 3.1 MVC app to azure将 ASP.NET CORE 3.1 MVC 应用程序部署到天蓝色时出现问题
【发布时间】:2020-09-12 15:01:45
【问题描述】:

主要问题是数据库。我有一个使用 Microsoft SQL Managment Studio 创建的本地数据库,它是我希望我的应用程序使用的数据库,因为我有一个注册/登录/凭据系统。我用自己的数据库在 Azure 中创建了一个 SQL Server,其想法是将数据从本地数据库复制到新数据库。我还创建了一个应用服务计划和一个应用服务。我已经下载了它的发布配置文件以在上传时使用它。然后我编辑它的设置并添加

Server=tcp:csptest06.database.windows.net,1433;Initial Catalog=csptestDB06;Persist Security Info=False;User ID=JoseAdmin;Password=******;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;

在默认连接和实体框架迁移上,然后发布它。起初它无法连接,因为我没有添加我的 ip,但之后它只是给了我这个错误:

Gravedad    Código  Descripción Proyecto    Archivo Línea   Estado suprimido
Error       Web deployment task failed. (Error durante la ejecución del script de la base de datos. El error ocurrió entre las siguientes líneas del script: "326" y "342". El registro detallado podría tener más información acerca del error. El comando comenzaba con lo siguiente:
"IF NOT EXISTS(SELECT * FROM [__EFMigrationsHisto"
 There is already an object named 'TUsers' in the database. http://go.microsoft.com/fwlink/?LinkId=178587  Obtenga más información en: http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_SQL_EXECUTION_FAILURE.)
Failed to publish the database. This can happen if the remote database cannot run the script. Try modifying the database scripts, or disabling database publishing in the Package/Publish Web properties page. If the script failed due to database tables already exist, try dropping existing database objects before creating new ones. For more information on doing these options from Visual Studio, see http://go.microsoft.com/fwlink/?LinkId=179181.
Error details:
Error durante la ejecución del script de la base de datos. El error ocurrió entre las siguientes líneas del script: "326" y "342". El registro detallado podría tener más información acerca del error. El comando comenzaba con lo siguiente:
"IF NOT EXISTS(SELECT * FROM [__EFMigrationsHisto"
 There is already an object named 'TUsers' in the database. http://go.microsoft.com/fwlink/?LinkId=178587  Obtenga más información en: http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_SQL_EXECUTION_FAILURE.
There is already an object named 'TUsers' in the database.
   at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
   at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
   at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
   at System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async, Int32 timeout, Boolean asyncWrite)
   at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry)
   at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
   at Microsoft.Web.Deployment.DBStatementInfo.Execute(DbConnection connection, DbTransaction transaction, DeploymentBaseContext baseContext, Int32 timeout)    CSP0308     0   

关于如何解决这个问题的任何想法?我对编程比较陌生,所以请不要害怕一步一步地实现你的想法

【问题讨论】:

  • There is already an object named 'TUsers' in the database.,它给出了这个错误。
  • 是的,我意识到这确实是错误,我不明白为什么首先是错误。是否将我的数据库(本地数据库)上传到天蓝色的过程中?如果是这样的话,它有麻烦吗?我是否有第二个 TUsers 表我不知道并且需要删除?

标签: c# .net azure asp.net-core-mvc


【解决方案1】:

已修复并成功发布。如果有人想知道这就是我的做法:

已关注此视频:How to upload your local database to AZURE

从那时起,我从 Visual Studio 连接到托管在 azure 中的数据库。删除了我复制所有表的迁移,然后我从那里复制了连接字符串并发布了它。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-02-02
    • 1970-01-01
    • 1970-01-01
    • 2015-02-11
    • 1970-01-01
    • 2017-05-22
    • 2016-06-01
    • 1970-01-01
    相关资源
    最近更新 更多