The following entries where made in the Program.cs file following the Elsa Workflows instructions:
// Configure Management layer to use EF Core.
elsa.UseWorkflowManagement(management => management.UseEntityFrameworkCore(feature => feature.UseSqlServer()));
// Configure Runtime layer to use EF Core.
elsa.UseWorkflowRuntime(runtime => runtime.UseEntityFrameworkCore(feature => feature.UseSqlServer()));
Those entries are creating these errors:
'WorkflowManagementPersistenceFeature' does not contain a definition for 'UseSqlServer' and the best extension method overload 'SqlServerDbContextOptionsExtensions.UseSqlServer(DbContextOptionsBuilder, Action?)' requires a receiver of type 'Microsoft.EntityFrameworkCore.DbContextOptionsBuilder'
'EFCoreWorkflowRuntimePersistenceFeature' does not contain a definition for 'UseSqlServer' and the best extension method overload 'SqlServerDbContextOptionsExtensions.UseSqlServer(DbContextOptionsBuilder, Action?)' requires a receiver of type 'Microsoft.EntityFrameworkCore.DbContextOptionsBuilder'
Full Program.cs file:
using Elsa.EntityFrameworkCore.Modules.Management;
using Elsa.EntityFrameworkCore.Modules.Runtime;
using Elsa.Extensions;
using ElsaWorkflows.Components;
using ElsaWorkflows.Components.Account;
using ElsaWorkflows.Data;
using Microsoft.AspNetCore.Components.Authorization;
using Microsoft.AspNetCore.Identity;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.SqlServer;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddRazorComponents()
.AddInteractiveServerComponents();
builder.Services.AddCascadingAuthenticationState();
builder.Services.AddScoped<IdentityUserAccessor>();
builder.Services.AddScoped<IdentityRedirectManager>();
builder.Services.AddScoped<AuthenticationStateProvider, IdentityRevalidatingAuthenticationStateProvider>();
builder.Services.AddAuthentication(options =>
{
options.DefaultScheme = IdentityConstants.ApplicationScheme;
options.DefaultSignInScheme = IdentityConstants.ExternalScheme;
})
.AddIdentityCookies();
var connectionString = builder.Configuration.GetConnectionString("DefaultConnection") ?? throw new InvalidOperationException("Connection string 'DefaultConnection' not found.");
builder.Services.AddDbContext<ApplicationDbContext>(options =>
options.UseSqlServer(connectionString));
builder.Services.AddDatabaseDeveloperPageExceptionFilter();
builder.Services.AddIdentityCore<ApplicationUser>(options => options.SignIn.RequireConfirmedAccount = true)
.AddEntityFrameworkStores<ApplicationDbContext>()
.AddSignInManager()
.AddDefaultTokenProviders();
builder.Services.AddSingleton<IEmailSender<ApplicationUser>, IdentityNoOpEmailSender>();
builder.Services.AddElsa(elsa =>
{
// Configure Management layer to use EF Core.
elsa.UseWorkflowManagement(management => management.UseEntityFrameworkCore(ef => ef.UseSqlServer()));
// Configure Runtime layer to use EF Core.
elsa.UseWorkflowRuntime(runtime => runtime.UseEntityFrameworkCore(ef => ef.UseSqlServer()));
// Default Identity features for authentication/authorization.
elsa.UseIdentity(identity =>
{
identity.TokenOptions = options => options.SigningKey = "SigningKeyHere"; // This key needs to be at least 256 bits long.
identity.UseAdminUserProvider();
});
// Configure ASP.NET authentication/authorization.
elsa.UseDefaultAuthentication(auth => auth.UseAdminApiKey());
// Expose Elsa API endpoints.
elsa.UseWorkflowsApi();
// Enable JavaScript workflow expressions.
elsa.UseJavaScript();
// Enable C# workflow expressions.
elsa.UseCSharp();
// Enable Liquid workflow expressions.
elsa.UseLiquid();
// Enable HTTP activities.
elsa.UseHttp();
// Use timer activities.
elsa.UseScheduling();
// Register custom activities from the application, if any.
elsa.AddActivitiesFrom<Program>();
// Register custom workflows from the application, if any.
elsa.AddWorkflowsFrom<Program>();
});
// Configure CORS to allow designer app hosted on a different origin to invoke the APIs.
builder.Services.AddCors(cors => cors
.AddDefaultPolicy(policy => policy
.AllowAnyOrigin() // For demo purposes only. Use a specific origin instead.
.AllowAnyHeader()
.AllowAnyMethod()
.WithExposedHeaders("x-elsa-workflow-instance-id"))); // Required for Elsa Studio in order to support running workflows from the designer. Alternatively, you can use the `*` wildcard to expose all headers.
// Add Health Checks.
builder.Services.AddHealthChecks();
var app = builder.Build();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseMigrationsEndPoint();
}
else
{
app.UseExceptionHandler("/Error", createScopeForErrors: true);
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}
app.UseCors();
app.UseHttpsRedirection();
app.UseStaticFiles();
// Elsa middleware
app.UseWorkflowsApi(); // Use Elsa API endpoints.
app.UseWorkflows(); // Use Elsa middleware to handle HTTP requests mapped to HTTP Endpoint activities.
app.UseAntiforgery();
app.MapRazorComponents<App>()
.AddInteractiveServerRenderMode();
// Add additional endpoints required by the Identity /Account Razor components.
app.MapAdditionalIdentityEndpoints();
app.Run();
I have searched on the Elsa Workflows documentation website for information on the SQL Server configuration and have found nothing.
I looked through StackOverflow and found this configuration answer as I could not find an answer or the information was too old.
I have also done general web searches and AI searches without success.
Where do I find info about it or, what is the correct way to configure Elsa Workflows for ASP.NET 8 with Server-Side Blazor Pages?
Program.csthat has been posted is configured toUseSqlite()so it shouldn't be throwing that error. Have you seen Configure Elsa 3 migration to SQL Server #5706?