Skip to content

Commit

Permalink
Using native EF Core 2.0 mapping configuration instead unnecessary cu…
Browse files Browse the repository at this point in the history
…stom extensions
  • Loading branch information
andreluizsecco committed Sep 27, 2017
1 parent 4c8e881 commit 3447370
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 37 deletions.
3 changes: 1 addition & 2 deletions src/Equinox.Infra.Data/Context/EquinoxContext.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System.IO;
using Equinox.Domain.Models;
using Equinox.Infra.Data.Mappings;
using Equinox.Infra.Data.Extensions;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;

Expand All @@ -13,7 +12,7 @@ public class EquinoxContext : DbContext

protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.AddConfiguration(new CustomerMap());
modelBuilder.ApplyConfiguration(new CustomerMap());

base.OnModelCreating(modelBuilder);
}
Expand Down
3 changes: 1 addition & 2 deletions src/Equinox.Infra.Data/Context/EventStoreSQLContext.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System.IO;
using Equinox.Domain.Core.Events;
using Equinox.Infra.Data.Mappings;
using Equinox.Infra.Data.Extensions;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;

Expand All @@ -14,7 +13,7 @@ public class EventStoreSQLContext : DbContext

protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.AddConfiguration(new StoredEventMap());
modelBuilder.ApplyConfiguration(new StoredEventMap());

base.OnModelCreating(modelBuilder);
}
Expand Down
12 changes: 0 additions & 12 deletions src/Equinox.Infra.Data/Extensions/EntityTypeConfiguration.cs

This file was deleted.

12 changes: 0 additions & 12 deletions src/Equinox.Infra.Data/Extensions/ModelBuilderExtensions.cs

This file was deleted.

6 changes: 2 additions & 4 deletions src/Equinox.Infra.Data/Mappings/CustomerMap.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Equinox.Domain.Models;
using Equinox.Infra.Data.Extensions;


namespace Equinox.Infra.Data.Mappings
{
public class CustomerMap : EntityTypeConfiguration<Customer>
public class CustomerMap : IEntityTypeConfiguration<Customer>
{
public override void Map(EntityTypeBuilder<Customer> builder)
public void Configure(EntityTypeBuilder<Customer> builder)
{
builder.Property(c => c.Id)
.HasColumnName("Id");
Expand Down
7 changes: 2 additions & 5 deletions src/Equinox.Infra.Data/Mappings/StoredEventMap.cs
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Equinox.Infra.Data.Extensions;
using Equinox.Domain.Core.Events;


namespace Equinox.Infra.Data.Mappings
{
public class StoredEventMap : EntityTypeConfiguration<StoredEvent>
public class StoredEventMap : IEntityTypeConfiguration<StoredEvent>
{
public override void Map(EntityTypeBuilder<StoredEvent> builder)
public void Configure(EntityTypeBuilder<StoredEvent> builder)
{
builder.Property(c => c.Timestamp)
.HasColumnName("CreationDate");

builder.Property(c => c.MessageType)
.HasColumnName("Action")
.HasColumnType("varchar(100)");

}
}
}

0 comments on commit 3447370

Please sign in to comment.