forked from danielgerlag/workflow-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MysqlContext.cs
63 lines (54 loc) · 2.44 KB
/
MysqlContext.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using WorkflowCore.Persistence.EntityFramework.Models;
using WorkflowCore.Persistence.EntityFramework.Services;
namespace WorkflowCore.Persistence.MySQL
{
public class MysqlContext : WorkflowDbContext
{
private readonly string _connectionString;
private readonly Action<MySqlDbContextOptionsBuilder> _mysqlOptionsAction;
public MysqlContext(string connectionString, Action<MySqlDbContextOptionsBuilder> mysqlOptionsAction = null)
{
_connectionString = connectionString;
_mysqlOptionsAction = mysqlOptionsAction;
}
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
base.OnConfiguring(optionsBuilder);
optionsBuilder.UseMySql(_connectionString, _mysqlOptionsAction);
}
protected override void ConfigureSubscriptionStorage(EntityTypeBuilder<PersistedSubscription> builder)
{
builder.ToTable("Subscription");
builder.Property(x => x.PersistenceId).ValueGeneratedOnAdd();
}
protected override void ConfigureWorkflowStorage(EntityTypeBuilder<PersistedWorkflow> builder)
{
builder.ToTable("Workflow");
builder.Property(x => x.PersistenceId).ValueGeneratedOnAdd();
}
protected override void ConfigureExecutionPointerStorage(EntityTypeBuilder<PersistedExecutionPointer> builder)
{
builder.ToTable("ExecutionPointer");
builder.Property(x => x.PersistenceId).ValueGeneratedOnAdd();
}
protected override void ConfigureExecutionErrorStorage(EntityTypeBuilder<PersistedExecutionError> builder)
{
builder.ToTable("ExecutionError");
builder.Property(x => x.PersistenceId).ValueGeneratedOnAdd();
}
protected override void ConfigureExetensionAttributeStorage(EntityTypeBuilder<PersistedExtensionAttribute> builder)
{
builder.ToTable("ExtensionAttribute");
builder.Property(x => x.PersistenceId).ValueGeneratedOnAdd();
}
protected override void ConfigureEventStorage(EntityTypeBuilder<PersistedEvent> builder)
{
builder.ToTable("Event");
builder.Property(x => x.PersistenceId).ValueGeneratedOnAdd();
}
}
}