Skip to content

Commit d96fcbf

Browse files
authored
feat(EntityFramework): Support migration of local message table via IDesignTimeDbContextFactory<TContext> (#152)
* feat(EntityFramework): Support migration of local message table via IDesignTimeDbContextFactory<TContext> * doc: Modify the use of cross-process events documentation * feat(EntityFramework): Support migration of local message table via IDesignTimeDbContextFactory<TContext>
1 parent 9cdacbd commit d96fcbf

File tree

6 files changed

+50
-42
lines changed

6 files changed

+50
-42
lines changed

src/Ddd/Masa.Contrib.Ddd.Domain/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Install-Package Masa.Contrib.Data.EntityFrameworkCore.SqlServer
2222
builder.Services
2323
.AddDomainEventBus(options =>
2424
{
25-
options.UseIntegrationEventBus<IntegrationEventLogService>(opt =>
25+
options.UseIntegrationEventBus(opt =>
2626
{
2727
opt.UseDapr();
2828
opt.UseEventLog<CustomizeDbContext>();//Use cross-process events

src/Ddd/Masa.Contrib.Ddd.Domain/README.zh-CN.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Install-Package Masa.Contrib.Data.EntityFrameworkCore.SqlServer
2222
builder.Services
2323
.AddDomainEventBus(options =>
2424
{
25-
options.UseIntegrationEventBus<IntegrationEventLogService>(opt =>
25+
options.UseIntegrationEventBus(opt =>
2626
{
2727
opt.UseDapr();
2828
opt.UseEventLog<CustomizeDbContext>();//使用跨进程事件
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// Copyright (c) MASA Stack All rights reserved.
2+
// Licensed under the MIT License. See LICENSE.txt in the project root for license information.
3+
4+
namespace Masa.Contrib.Dispatcher.IntegrationEvents.EventLogs.EF;
5+
6+
public class IntegrationEventLogEntityTypeConfiguration: IEntityTypeConfiguration<IntegrationEventLog>
7+
{
8+
public void Configure(EntityTypeBuilder<IntegrationEventLog> builder)
9+
{
10+
builder.ToTable("IntegrationEventLog");
11+
12+
builder.HasKey(e => e.Id);
13+
14+
builder.Property(e => e.Id)
15+
.IsRequired();
16+
17+
builder.Property(e => e.Content)
18+
.IsRequired();
19+
20+
builder.Property(e => e.CreationTime)
21+
.IsRequired();
22+
23+
builder.Property(e => e.ModificationTime)
24+
.IsRequired();
25+
26+
builder.Property(e => e.State)
27+
.IsRequired();
28+
29+
builder.Property(e => e.TimesSent)
30+
.IsRequired();
31+
32+
builder.Property(nameof(IHasConcurrencyStamp.RowVersion))
33+
.IsConcurrencyToken()
34+
.HasMaxLength(36)
35+
.HasColumnName(nameof(IHasConcurrencyStamp.RowVersion));
36+
37+
builder.Property(e => e.EventTypeName)
38+
.IsRequired();
39+
40+
builder.HasIndex(e => new { e.State, e.ModificationTime }, "index_state_modificationtime");
41+
builder.HasIndex(e => new { e.State, e.TimesSent, e.ModificationTime }, "index_state_timessent_modificationtime");
42+
builder.HasIndex(e => new { e.EventId, e.RowVersion }, "index_eventid_version");
43+
}
44+
}

src/Dispatcher/Masa.Contrib.Dispatcher.IntegrationEvents.EventLogs.EF/IntegrationEventLogModelCreatingProvider.cs

+2-38
Original file line numberDiff line numberDiff line change
@@ -7,43 +7,7 @@ public class IntegrationEventLogModelCreatingProvider : IModelCreatingProvider
77
{
88
public void Configure(ModelBuilder modelBuilder)
99
{
10-
modelBuilder.Entity<IntegrationEventLog>(ConfigureEventLogEntry);
11-
}
12-
13-
private void ConfigureEventLogEntry(EntityTypeBuilder<IntegrationEventLog> builder)
14-
{
15-
builder.ToTable("IntegrationEventLog");
16-
17-
builder.HasKey(e => e.Id);
18-
19-
builder.Property(e => e.Id)
20-
.IsRequired();
21-
22-
builder.Property(e => e.Content)
23-
.IsRequired();
24-
25-
builder.Property(e => e.CreationTime)
26-
.IsRequired();
27-
28-
builder.Property(e => e.ModificationTime)
29-
.IsRequired();
30-
31-
builder.Property(e => e.State)
32-
.IsRequired();
33-
34-
builder.Property(e => e.TimesSent)
35-
.IsRequired();
36-
37-
builder.Property(nameof(IHasConcurrencyStamp.RowVersion))
38-
.IsConcurrencyToken()
39-
.HasMaxLength(36)
40-
.HasColumnName(nameof(IHasConcurrencyStamp.RowVersion));
41-
42-
builder.Property(e => e.EventTypeName)
43-
.IsRequired();
44-
45-
builder.HasIndex(e => new { e.State, e.ModificationTime }, "index_state_modificationtime");
46-
builder.HasIndex(e => new { e.State, e.TimesSent, e.ModificationTime }, "index_state_timessent_modificationtime");
47-
builder.HasIndex(e => new { e.EventId, e.RowVersion }, "index_eventid_version");
10+
var integrationEventLogEntityTypeConfiguration = new IntegrationEventLogEntityTypeConfiguration();
11+
modelBuilder.Entity<IntegrationEventLog>(integrationEventLogEntityTypeConfiguration.Configure);
4812
}
4913
}

src/Dispatcher/Masa.Contrib.Dispatcher.IntegrationEvents.EventLogs.EF/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Install-Package Masa.Contrib.Dispatcher.IntegrationEvents.EventLogs.EF
1313
1. Add EventLogs.EF
1414

1515
```C#
16-
.AddDaprEventBus<IntegrationEventLogService>(options =>
16+
.AddIntegrationEventBus(options =>
1717
{
1818
options
1919
// TODO

src/Dispatcher/Masa.Contrib.Dispatcher.IntegrationEvents.EventLogs.EF/README.zh-CN.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Install-Package Masa.Contrib.Dispatcher.IntegrationEvents.EventLogs.EF
1313
1. 使用EventLogs.EF
1414

1515
```C#
16-
.AddDaprEventBus<IntegrationEventLogService>(options =>
16+
.AddIntegrationEventBus(options =>
1717
{
1818
options
1919
// TODO

0 commit comments

Comments
 (0)