Elsa Core 之 EF Core 相关


创建与更新表 startup.cs

sqlite

var contextFactory = new Elsa.Persistence.EntityFramework.Sqlite.SqliteElsaContextFactory();
var context = contextFactory.CreateDbContext(new string[1] { Configuration.GetConnectionString("ElsaConnection") });
context.Database.Migrate();
context.Database.EnsureCreated();

mysql

var contextFactory = new Elsa.Persistence.EntityFramework.MySql.MySqlElsaContextFactory();
var context = contextFactory.CreateDbContext(new string[2] { Configuration.GetConnectionString("ElsaConnection"), "5.7.28" });
context.Database.Migrate();
context.Database.EnsureCreated();

sqlserver

var contextFactory = new Elsa.Persistence.EntityFramework.SqlServer.SqlServerElsaContextFactory();
var context = contextFactory.CreateDbContext(new string[1] { Configuration.GetConnectionString("ElsaConnection")});
context.Database.Migrate();
context.Database.EnsureCreated();

关键字: elsa、数据库、生成表、创建表