elsa-core/src/samples/Sample23/ElsaContextFactory.cs
Sipke Schoorstra 8092d166a5
Add native .NET code support + activity input/output (#216)
* Add code activity

* Refactor Workflow State to use Variables

* Update InstantEvent and SetVariable

* Update samples

* Add activity input/output
2019-12-23 21:43:11 +01:00

34 lines
1.3 KiB
C#

using Elsa;
using Elsa.Persistence.EntityFrameworkCore.CustomSchema;
using Elsa.Persistence.EntityFrameworkCore.DbContexts;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design;
using Microsoft.Extensions.DependencyInjection;
namespace Sample23
{
public class ElsaContextFactory : IDesignTimeDbContextFactory<ElsaContext>
{
public ElsaContext CreateDbContext(string[] args)
{
// Migrations added to Sample23.CustomMigration with the following Powershell command
// Add-Migration InitialCreate -context ElsaContext -Project Sample23.CustomMigration
var services = new ServiceCollection();
ElsaBuilder elsaBuilder = new ElsaBuilder(services);
elsaBuilder.AddCustomSchema("elsa");
var optionsBuilder = new DbContextOptionsBuilder<ElsaContext>();
optionsBuilder.UseSqlite(
@"Data Source=c:\data\elsa.entity-framework-core.db;Cache=Shared",
x =>
{
x.AddCustomSchemaModelSupport(optionsBuilder, elsaBuilder.Services);
x.MigrationsAssembly(typeof(Program).Assembly.FullName);
x.MigrationsHistoryTableWithSchema(optionsBuilder);
});
return new ElsaContext(optionsBuilder.Options);
}
}
}