繁体   English   中英

将 ASP.NET CORE 3.1 MVC 应用程序部署到 azure 时出现问题

[英]Problem deploying ASP.NET CORE 3.1 MVC app to azure

主要问题是数据库。 我有一个使用 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   

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

修复它并成功发布它。 如果有人想知道我是如何做到的:

关注此视频:如何将本地数据库上传到 AZURE

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM