Skip to content

Commit

Permalink
add Elsa.EntityFrameworkCore.MySql
Browse files Browse the repository at this point in the history
  • Loading branch information
gambitier committed May 22, 2023
1 parent 3b7081b commit 4407f44
Show file tree
Hide file tree
Showing 27 changed files with 2,228 additions and 13 deletions.
34 changes: 21 additions & 13 deletions Elsa.sln
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@

Microsoft Visual Studio Solution File, Format Version 12.00
#
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{61017E64-6D00-49CB-9E81-5002DC8F7D5F}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{155227F0-A33B-40AA-A4B4-06F813EB921B}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "common", "common", "{C6658DE0-2B2F-47F0-BB61-2CA66D435C09}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "solution", "solution", "{7D21EB5E-D6B4-48A5-A9BC-A26387A65F0B}"
ProjectSection(SolutionItems) = preProject
README.md = README.md
docker-compose.yml = docker-compose.yml
common.props = common.props
configureawait.props = configureawait.props
.gitignore = .gitignore
icon.png = icon.png
.github\workflows\packages.yml = .github\workflows\packages.yml
.github\workflows\all-in-one-web.yml = .github\workflows\all-in-one-web.yml
build-and-run-all-in-one-web-docker.sh = build-and-run-all-in-one-web-docker.sh
NuGet.Config = NuGet.Config
.github\workflows\npm-packages.yml = .github\workflows\npm-packages.yml
EndProjectSection
ProjectSection(SolutionItems) = preProject
README.md = README.md
docker-compose.yml = docker-compose.yml
common.props = common.props
configureawait.props = configureawait.props
.gitignore = .gitignore
icon.png = icon.png
.github\workflows\packages.yml = .github\workflows\packages.yml
.github\workflows\all-in-one-web.yml = .github\workflows\all-in-one-web.yml
build-and-run-all-in-one-web-docker.sh = build-and-run-all-in-one-web-docker.sh
NuGet.Config = NuGet.Config
.github\workflows\npm-packages.yml = .github\workflows\npm-packages.yml
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docs", "docs", "{0354F050-3992-4DD4-B0EE-5FBA04AC72B6}"
EndProject
Expand Down Expand Up @@ -200,6 +201,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.Samples.AspNet.HttpEnd
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.Environments", "src\modules\Elsa.Environments\Elsa.Environments.csproj", "{B5CDF747-8066-40D5-9BAE-CBE397BC9B51}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.EntityFrameworkCore.MySql", "src\modules\Elsa.EntityFrameworkCore.MySql\Elsa.EntityFrameworkCore.MySql.csproj", "{8DC74562-1F06-4AFA-8308-8A779E8812A3}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -510,6 +513,10 @@ Global
{B5CDF747-8066-40D5-9BAE-CBE397BC9B51}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B5CDF747-8066-40D5-9BAE-CBE397BC9B51}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B5CDF747-8066-40D5-9BAE-CBE397BC9B51}.Release|Any CPU.Build.0 = Release|Any CPU
{8DC74562-1F06-4AFA-8308-8A779E8812A3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8DC74562-1F06-4AFA-8308-8A779E8812A3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8DC74562-1F06-4AFA-8308-8A779E8812A3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8DC74562-1F06-4AFA-8308-8A779E8812A3}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{155227F0-A33B-40AA-A4B4-06F813EB921B} = {61017E64-6D00-49CB-9E81-5002DC8F7D5F}
Expand Down Expand Up @@ -599,5 +606,6 @@ Global
{3212A999-4AC4-4911-9AA4-92AB906BCB5E} = {56C2FFB8-EA54-45B5-A095-4A78142EB4B5}
{165ACC9D-B67C-4B49-A818-ECFD247C899C} = {56C2FFB8-EA54-45B5-A095-4A78142EB4B5}
{B5CDF747-8066-40D5-9BAE-CBE397BC9B51} = {5BA4A8FA-F7F4-45B3-AEC8-8886D35AAC79}
{8DC74562-1F06-4AFA-8308-8A779E8812A3} = {5BA4A8FA-F7F4-45B3-AEC8-8886D35AAC79}
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using Elsa.EntityFrameworkCore.Extensions;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design;

namespace Elsa.EntityFrameworkCore.MySql.Abstractions;

public abstract class MySqlDesignTimeDbContextFactoryBase<TDbContext> : IDesignTimeDbContextFactory<TDbContext> where TDbContext : DbContext
{
public TDbContext CreateDbContext(string[] args)
{
var connectionString = args.Any() ? args[0] : "Data Source=local";

var builder = new DbContextOptionsBuilder<TDbContext>();
builder.UseElsaMySql(connectionString);

return (TDbContext)Activator.CreateInstance(typeof(TDbContext), builder.Options)!;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<Project Sdk="Microsoft.NET.Sdk">

<Import Project="..\..\..\common.props" />
<Import Project="..\..\..\configureawait.props" />

<PropertyGroup>
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
<Description>
Provides MySql implementation and migrations for various modules.
</Description>
<PackageTags>elsa module persistence efcore MySql</PackageTags>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="7.0.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Elsa.EntityFrameworkCore\Elsa.EntityFrameworkCore.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using Elsa.EntityFrameworkCore.Common;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Pomelo.EntityFrameworkCore.MySql.Infrastructure;

// ReSharper disable once CheckNamespace
namespace Elsa.EntityFrameworkCore.Extensions;

public static class DbContextOptionsBuilderExtensions
{
public static DbContextOptionsBuilder UseElsaMySql(this DbContextOptionsBuilder builder, string connectionString, Action<MySqlDbContextOptionsBuilder>? configure = default) =>
builder.UseMySql(connectionString, ServerVersion.AutoDetect(connectionString), db =>
{
db
.MigrationsAssembly(typeof(DbContextOptionsBuilderExtensions).Assembly.GetName().Name)
.MigrationsHistoryTable(ElsaDbContextBase.MigrationsHistoryTable, ElsaDbContextBase.ElsaSchema)
.SchemaBehavior(MySqlSchemaBehavior.Ignore);

configure?.Invoke(db);
});
}
3 changes: 3 additions & 0 deletions src/modules/Elsa.EntityFrameworkCore.MySql/FodyWeavers.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
<ConfigureAwait />
</Weavers>

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 4407f44

Please sign in to comment.