Search code examples
c#asp.net-mvcasp.net-coreserenity-platform

New Serenity deployment failing on Azure with Invalid object name 'Languages'


Using Serenity framework v 5.0.24. I have a new solution with a small demo of something, all works locally but when I tried to deploy it to an Azure resource it seems to be failing to even create the database, but I can't figure out why. 'Languages' is the second thing in the initial migrations unit so I'm assuming its that. I've deployed dozens of serenity apps before on previous versions so I'm not a newcomer. Here's the raw exception output:

Microsoft.Data.SqlClient.SqlException (0x80131904): Invalid object name 'Languages'.
   at Microsoft.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
   at Microsoft.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
   at Microsoft.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
   at Microsoft.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
   at Microsoft.Data.SqlClient.SqlDataReader.TryConsumeMetaData()
   at Microsoft.Data.SqlClient.SqlDataReader.get_MetaData()
   at Microsoft.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString, Boolean isInternal, Boolean forDescribeParameterEncryption, Boolean shouldCacheForAlwaysEncrypted)
   at Microsoft.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean isAsync, Int32 timeout, Task& task, Boolean asyncWrite, Boolean inRetry, SqlDataReader ds, Boolean describeParameterEncryptionRequest)
   at Microsoft.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry, String method)
   at Microsoft.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
   at Microsoft.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior)
   at Microsoft.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
   at System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader()
   at Serenity.Data.SqlHelper.ExecuteReader(IDbConnection connection, String commandText, IDictionary`2 param, ILogger logger)
   at Serenity.Data.SqlHelper.ExecuteReader(IDbConnection connection, SqlQuery query, ILogger logger)
   at Serenity.Data.EntitySqlHelper.ForEach(SqlQuery query, IDbConnection connection, Action callBack)
   at Serenity.Web.RowLookupScript`1.GetItems()
   at Serenity.Web.LookupScript.GetScript()
   at Serenity.Web.DynamicScriptManager.<>c__DisplayClass16_0.<EnsureScriptContent>g__factory|0()
   at Serenity.TwoLevelCacheExtensions.GetInternal[TItem](ITwoLevelCache cache, String cacheKey, TimeSpan localExpiration, TimeSpan remoteExpiration, String groupKey, Func`1 loader, Boolean localOnly)
   at Serenity.TwoLevelCacheExtensions.GetLocalStoreOnly[TItem](ITwoLevelCache cache, String cacheKey, TimeSpan localExpiration, String groupKey, Func`1 loader)
   at Serenity.Web.DynamicScriptManager.<>c__DisplayClass16_0.<EnsureScriptContent>g__getOrCreate|1()
   at Serenity.Web.DynamicScriptManager.EnsureScriptContent(String name, IDynamicScript script)
   at Serenity.Web.DynamicScriptManager.GetScriptText(String name)
   at AspNetCore.Views_Shared__LayoutHead.ExecuteAsync() in C:\Projects\research\distanceSignOff\distanceSignOff.Web\Views\Shared\_LayoutHead.cshtml:line 21
   at Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderPageCoreAsync(IRazorPage page, ViewContext context)
   at Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderPageAsync(IRazorPage page, ViewContext context, Boolean invokeViewStarts)
   at Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderAsync(ViewContext context)
   at Microsoft.AspNetCore.Mvc.TagHelpers.PartialTagHelper.RenderPartialViewAsync(TextWriter writer, Object model, IView view)
   at Microsoft.AspNetCore.Mvc.TagHelpers.PartialTagHelper.ProcessAsync(TagHelperContext context, TagHelperOutput output)
   at Microsoft.AspNetCore.Razor.Runtime.TagHelpers.TagHelperRunner.<RunAsync>g__Awaited|0_0(Task task, TagHelperExecutionContext executionContext, Int32 i, Int32 count)
   at AspNetCore.Views_Shared__LayoutNoNavigation.<ExecuteAsync>b__9_0() in C:\Projects\research\distanceSignOff\distanceSignOff.Web\Views\Shared\_LayoutNoNavigation.cshtml:line 7
   at Microsoft.AspNetCore.Razor.Runtime.TagHelpers.TagHelperExecutionContext.SetOutputContentAsync()
   at AspNetCore.Views_Shared__LayoutNoNavigation.ExecuteAsync() in C:\Projects\research\distanceSignOff\distanceSignOff.Web\Views\Shared\_LayoutNoNavigation.cshtml:line 5
   at Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderPageCoreAsync(IRazorPage page, ViewContext context)
   at Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderPageAsync(IRazorPage page, ViewContext context, Boolean invokeViewStarts)
   at Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderLayoutAsync(ViewContext context, ViewBufferTextWriter bodyWriter)
   at Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderAsync(ViewContext context)
   at Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor.ExecuteAsync(ViewContext viewContext, String contentType, Nullable`1 statusCode)
   at Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor.ExecuteAsync(ViewContext viewContext, String contentType, Nullable`1 statusCode)
   at Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor.ExecuteAsync(ActionContext actionContext, IView view, ViewDataDictionary viewData, ITempDataDictionary tempData, String contentType, Nullable`1 statusCode)
   at Microsoft.AspNetCore.Mvc.ViewFeatures.ViewResultExecutor.ExecuteAsync(ActionContext context, ViewResult result)
   at Microsoft.AspNetCore.Mvc.ViewResult.ExecuteResultAsync(ActionContext context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResultFilterAsync>g__Awaited|29_0[TFilter,TFilterAsync](ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResultExecutedContextSealed context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.ResultNext[TFilter,TFilterAsync](State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeResultFilters()
--- End of stack trace from previous location ---
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g__Awaited|24_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeFilterPipelineAsync()
--- End of stack trace from previous location ---
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker)
   at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
   at StackExchange.Exceptional.ExceptionalMiddleware.Invoke(HttpContext context)
   at StackExchange.Exceptional.ExceptionalMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
ClientConnectionId:f3bf9b09-8ec0-45dd-b2e3-28445db434a9
Error Number:208,State:1,Class:16
ClientConnectionId before routing:6066e64d-1796-4b10-bf92-233e7990242a
Routing Destination:aed1b953e0aa.tr14046.eastus1-a.worker.database.windows.net,11009

Solution

  • For the benefit of others, I've found my own problem. I had overlooked the removal of the the migrations safety check in DataMigrations.cs around line 203, the part that stops you writing new databases willy-nilly. I remember (maybe) in the past the application would warn you that migrations had been skipped rather than just pull exceptions on the first SQL object not found. Easily done, but I feel a bit daft!