Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Monday, July 2, 2018 5:08 PM
Running the tutorial at https://docs.microsoft.com/en-us/aspnet/core/tutorials/first-mvc-app/?view=aspnetcore-2.1 I've been publishing all the way with no problems.
After adding the schedule code and testing it locally, it won't publish. the Error I'm getting is :
Publish failed
Publish has encountered an error.
Build failed. Check the Output window for more details.
A diagnostic log has been written to the following location:
"C:\Users\kztd\AppData\Local\Temp\tmp8A0.tmp"
OK
If I watch the build process it's failing after it says it's creating the database. Then I get this message:
Severity Code Description Project File Line Suppression State
Error Web deployment task failed. (An error occurred during execution of the database script. The error occurred between the following lines of the script: "74" and "87". The verbose log might have more information about the error. The command started with the following:
"IF NOT EXISTS(SELECT * FROM [__EFMigrationsHisto"
Cannot insert the value NULL into column 'Rating', table 'kzrazorpagesmovie18-1_db.dbo.Movie'; column does not allow nulls. UPDATE fails.
The statement has been terminated. http://go.microsoft.com/fwlink/?LinkId=178587 Learn more at: 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:
An error occurred during execution of the database script. The error occurred between the following lines of the script: "74" and "87". The verbose log might have more information about the error. The command started with the following:
"IF NOT EXISTS(SELECT * FROM [__EFMigrationsHisto"
Cannot insert the value NULL into column 'Rating', table 'kzrazorpagesmovie18-1_db.dbo.Movie'; column does not allow nulls. UPDATE fails.
The statement has been terminated. http://go.microsoft.com/fwlink/?LinkId=178587 Learn more at: http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_SQL_EXECUTION_FAILURE.
Cannot insert the value NULL into column 'Rating', table 'kzrazorpagesmovie18-1_db.dbo.Movie'; column does not allow nulls. UPDATE fails.
The statement has been terminated.
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) RazorPagesMovie 0
All replies (9)
Tuesday, July 3, 2018 5:09 AM
Clearly seems from the error log that the code in having the issue. Following snippet of error code explains that it cannot accepts ‘NULL’ value.

You can refer this link SQL script errors. Also you can refer here for more details. You can redeploy the code using automatically generated scripts. Refer here
If this answer was helpful, click “Mark as Answer” or “Up-Vote”. To provide additional feedback on your forum experience, click here
Thursday, July 5, 2018 5:35 AM
Just checking in to see if the above suggestions helped or you need further assistance on this specific issue.
Sunday, July 8, 2018 5:04 PM
ok thanks, yes that's not helpful at all.
If I had done that, tried to insert Null, then I could undo it, but I didn't. I was just following the tutorial and pushing my code up after I made changes. Also, when I run it locally, it runs fine.
The tutorial is using database migrations to modify the database, and mostly just added a new field, Rating, at around the 3rd step.
It looks like somewhere, somehow, it's trying to add a record that doesn't have a Rating, on publish, but why would it do that?
For this case, I'd be happy to drop the current database on Azure and have it just rebuild it from the migrations, but, that would be kind of extreme if the database actually had data in it.
So I'd like to understand is what is happening to the database when I push, and how do I control it.
Monday, July 9, 2018 3:42 AM
I would suggest you to have a look on the page, where you are adding “Rating”. There's nothing within web apps. You need to change/modify your code accordingly.
Wednesday, July 11, 2018 4:08 AM
Just checking in to see if the above suggestions helped or you need further assistance on this specific issue.
Friday, July 13, 2018 6:35 PM
> I would suggest you to have a look on the page, where you are adding “Rating”. There's nothing within web apps. You need to change/modify your code accordingly.
I don't think there is a 'page' where I added rating, I added it to the model a couple steps ago and it worked fine. It's also working locally, its just the push to Azure that is crashing. How do I debug that push process?
Sunday, July 15, 2018 11:07 AM
You can enable diagnostics logging for web apps, also you can manually attach a debugger to your Azure web app, refer here. You may also check, what happens to your app during deployment.
Tuesday, July 17, 2018 6:26 AM
Just checking in to see if the above suggestions helped or you need further assistance on this specific issue.
Friday, December 6, 2019 5:28 PM
I ran in to the same issue. The instructions under the "Add a new field section" of the tutorial, despite being described as optional, are in fact not. Do the following:
- Go to View > SQL Server Object Explorer.
- Delete your database (ensure that "close existing connections" is checked).
- Click OK.
- Go to Tools > NuGet Package Manager > Package Manager Console
- Utilize the Update-Database PowerShell command.