-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
gambitier
committed
May 22, 2023
1 parent
3b7081b
commit 4407f44
Showing
27 changed files
with
2,228 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
...es/Elsa.EntityFrameworkCore.MySql/Abstractions/SqlServerDesignTimeDbContextFactoryBase.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)!; | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
src/modules/Elsa.EntityFrameworkCore.MySql/Elsa.EntityFrameworkCore.MySql.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
21 changes: 21 additions & 0 deletions
21
src/modules/Elsa.EntityFrameworkCore.MySql/Extensions/DbContextOptionsBuilderExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
128 changes: 128 additions & 0 deletions
128
...les/Elsa.EntityFrameworkCore.MySql/Migrations/Identity/20230517105414_Initial.Designer.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.