I'm using Coravel pro trial and had a hard time with the DbContext.
We do not use migrations and use only database first approach. Whenever I run the app the app crashes at
app.UseCoravelPro();
and here is my sql script:
create table dbo.CoravelJobHistory(
Id int identity primary key,
StartedAt datetime null,
EndedAt datetime null ,
TypeFullPath nvarchar(max),
DisplayName nvarchar(max),
Failed bit,
ErrorMessage nvarchar(max),
StackTrace nvarchar(max)
)
go
create table dbo.CoravelScheduledJob(
Id int identity not null primary key,
InvocableFullPath nvarchar(max),
CronExpression nvarchar(max),
Frequency nvarchar(max),
Days nvarchar(max),
PreventOverlapping bit,
CreatedAt datetime,
Active bit
)
go
create table dbo.CoravelScheduledJobHistory (
Id int identity primary key,
EndedAt datetime null,
TypeFullPath nvarchar(max),
DisplayName nvarchar(max),
Failed bit,
ErrorMessage nvarchar(max),
StackTrace nvarchar(max)
)
go
the exception that is thrown at the UseCoravelPro() says:
System.Data.SqlClient.SqlException
HResult=0x80131904
Message=Invalid object name 'Coravel_JobHistory'.
Source=Core .Net SqlClient Data Provider
StackTrace:
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action1 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.SqlDataReader.TryConsumeMetaData() at System.Data.SqlClient.SqlDataReader.get_MetaData() at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, SqlDataReader ds) at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior) at Microsoft.EntityFrameworkCore.Storage.Internal.RelationalCommand.Execute(IRelationalConnection connection, DbCommandMethod executeMethod, IReadOnlyDictionary
2 parameterValues)
at Microsoft.EntityFrameworkCore.Storage.Internal.RelationalCommand.ExecuteReader(IRelationalConnection connection, IReadOnlyDictionary2 parameterValues) at Microsoft.EntityFrameworkCore.Query.Internal.QueryingEnumerable
1.Enumerator.BufferlessMoveNext(DbContext _, Boolean buffer)
at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerExecutionStrategy.Execute[TState,TResult](TState state, Func3 operation, Func
3 verifySucceeded)
at Microsoft.EntityFrameworkCore.Query.Internal.QueryingEnumerable1.Enumerator.MoveNext() at Microsoft.EntityFrameworkCore.Query.Internal.LinqOperatorProvider.<_TrackEntities>d__17
2.MoveNext()
at Microsoft.EntityFrameworkCore.Query.Internal.LinqOperatorProvider.ExceptionInterceptor1.EnumeratorExceptionInterceptor.MoveNext() at System.Collections.Generic.List
1.AddEnumerable(IEnumerable1 enumerable) at System.Linq.Enumerable.ToList[TSource](IEnumerable
1 source)
at Coravel.Pro.Features.Jobs.UseCases.MarkJobsKilledByTerminatedProcessCommand.Invoke()
at Coravel.Pro.ServiceRegistration.MarkJobsTerminatedByPreviouslyKilledProcess(IApplicationBuilder app)
at Coravel.Pro.ServiceRegistration.UseCoravelPro(IApplicationBuilder app)
at NQ.Jobs.CoravelStartup.Configure(IApplicationBuilder app) in D:\Projects\Quantum\source\API\NQ.Jobs\CoravelStartup.cs:line 26
at NQ.Api.Framework.Startup.Microsoft.AspNetCore.Hosting.IStartup.Configure(IApplicationBuilder app) in D:\Projects\Quantum\source\API\NQ.Platform\NQ.API\Framework\Startup.cs:line 141
at Microsoft.AspNetCore.Mvc.Internal.MiddlewareFilterBuilderStartupFilter.<>c__DisplayClass0_0.g__MiddlewareFilterBuilder|0(IApplicationBuilder builder)
at Microsoft.AspNetCore.HostFilteringStartupFilter.<>c__DisplayClass0_0.b__0(IApplicationBuilder app)
at Microsoft.AspNetCore.Hosting.Internal.AutoRequestServicesStartupFilter.<>c__DisplayClass0_0.b__0(IApplicationBuilder builder)
at Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication()
This exception was originally thrown at this call stack:
System.Data.SqlClient.SqlConnection.OnError(System.Data.SqlClient.SqlException, bool, System.Action<System.Action>)
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(System.Data.SqlClient.TdsParserStateObject, bool, bool)
System.Data.SqlClient.TdsParser.TryRun(System.Data.SqlClient.RunBehavior, System.Data.SqlClient.SqlCommand, System.Data.SqlClient.SqlDataReader, System.Data.SqlClient.BulkCopySimpleResultSet, System.Data.SqlClient.TdsParserStateObject, out bool)
System.Data.SqlClient.SqlDataReader.TryConsumeMetaData()
System.Data.SqlClient.SqlDataReader.MetaData.get()
System.Data.SqlClient.SqlCommand.FinishExecuteReader(System.Data.SqlClient.SqlDataReader, System.Data.SqlClient.RunBehavior, string)
System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(System.Data.CommandBehavior, System.Data.SqlClient.RunBehavior, bool, bool, int, out System.Threading.Tasks.Task, bool, System.Data.SqlClient.SqlDataReader)
System.Data.SqlClient.SqlCommand.ExecuteReader(System.Data.CommandBehavior)
Microsoft.EntityFrameworkCore.Storage.Internal.RelationalCommand.Execute(Microsoft.EntityFrameworkCore.Storage.IRelationalConnection, Microsoft.EntityFrameworkCore.Diagnostics.DbCommandMethod, System.Collections.Generic.IReadOnlyDictionary<string, object>)
Microsoft.EntityFrameworkCore.Storage.Internal.RelationalCommand.ExecuteReader(Microsoft.EntityFrameworkCore.Storage.IRelationalConnection, System.Collections.Generic.IReadOnlyDictionary<string, object>)
...
[Call Stack Truncated]
What am I missing in the DB Script?