forked from dotnet-architecture/eShopOnWeb
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated packages; Using configuration classes for EF Core.
- Loading branch information
Showing
21 changed files
with
599 additions
and
153 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
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
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
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,31 @@ | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.EntityFrameworkCore.Metadata.Builders; | ||
using Microsoft.eShopWeb.ApplicationCore.Entities.OrderAggregate; | ||
|
||
namespace Microsoft.eShopWeb.Infrastructure.Data.Config | ||
{ | ||
public class AddressConfiguration : IEntityTypeConfiguration<Address> | ||
{ | ||
public void Configure(EntityTypeBuilder<Address> builder) | ||
{ | ||
builder.Property(a => a.ZipCode) | ||
.HasMaxLength(18) | ||
.IsRequired(); | ||
|
||
builder.Property(a => a.Street) | ||
.HasMaxLength(180) | ||
.IsRequired(); | ||
|
||
builder.Property(a => a.State) | ||
.HasMaxLength(60); | ||
|
||
builder.Property(a => a.Country) | ||
.HasMaxLength(90) | ||
.IsRequired(); | ||
|
||
builder.Property(a => a.City) | ||
.HasMaxLength(100) | ||
.IsRequired(); | ||
} | ||
} | ||
} |
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,19 @@ | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.EntityFrameworkCore.Metadata.Builders; | ||
using Microsoft.eShopWeb.ApplicationCore.Entities.BasketAggregate; | ||
|
||
namespace Microsoft.eShopWeb.Infrastructure.Data.Config | ||
{ | ||
public class BasketConfiguration : IEntityTypeConfiguration<Basket> | ||
{ | ||
public void Configure(EntityTypeBuilder<Basket> builder) | ||
{ | ||
var navigation = builder.Metadata.FindNavigation(nameof(Basket.Items)); | ||
navigation.SetPropertyAccessMode(PropertyAccessMode.Field); | ||
|
||
builder.Property(b => b.BuyerId) | ||
.IsRequired() | ||
.HasMaxLength(20); | ||
} | ||
} | ||
} |
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,16 @@ | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.EntityFrameworkCore.Metadata.Builders; | ||
using Microsoft.eShopWeb.ApplicationCore.Entities.BasketAggregate; | ||
|
||
namespace Microsoft.eShopWeb.Infrastructure.Data.Config | ||
{ | ||
public class BasketItemConfiguration : IEntityTypeConfiguration<BasketItem> | ||
{ | ||
public void Configure(EntityTypeBuilder<BasketItem> builder) | ||
{ | ||
builder.Property(bi => bi.UnitPrice) | ||
.IsRequired(true) | ||
.HasColumnType("decimal(18,2)"); | ||
} | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
src/Infrastructure/Data/Config/CatalogBrandConfiguration.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,22 @@ | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.EntityFrameworkCore.Metadata.Builders; | ||
using Microsoft.eShopWeb.ApplicationCore.Entities; | ||
|
||
namespace Microsoft.eShopWeb.Infrastructure.Data.Config | ||
{ | ||
public class CatalogBrandConfiguration : IEntityTypeConfiguration<CatalogBrand> | ||
{ | ||
public void Configure(EntityTypeBuilder<CatalogBrand> builder) | ||
{ | ||
builder.HasKey(ci => ci.Id); | ||
|
||
builder.Property(ci => ci.Id) | ||
.ForSqlServerUseSequenceHiLo("catalog_brand_hilo") | ||
.IsRequired(); | ||
|
||
builder.Property(cb => cb.Brand) | ||
.IsRequired() | ||
.HasMaxLength(100); | ||
} | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
src/Infrastructure/Data/Config/CatalogItemConfiguration.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,37 @@ | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.EntityFrameworkCore.Metadata.Builders; | ||
using Microsoft.eShopWeb.ApplicationCore.Entities; | ||
|
||
namespace Microsoft.eShopWeb.Infrastructure.Data.Config | ||
{ | ||
public class CatalogItemConfiguration : IEntityTypeConfiguration<CatalogItem> | ||
{ | ||
public void Configure(EntityTypeBuilder<CatalogItem> builder) | ||
{ | ||
builder.ToTable("Catalog"); | ||
|
||
builder.Property(ci => ci.Id) | ||
.ForSqlServerUseSequenceHiLo("catalog_hilo") | ||
.IsRequired(); | ||
|
||
builder.Property(ci => ci.Name) | ||
.IsRequired(true) | ||
.HasMaxLength(50); | ||
|
||
builder.Property(ci => ci.Price) | ||
.IsRequired(true) | ||
.HasColumnType("decimal(18,2)"); | ||
|
||
builder.Property(ci => ci.PictureUri) | ||
.IsRequired(false); | ||
|
||
builder.HasOne(ci => ci.CatalogBrand) | ||
.WithMany() | ||
.HasForeignKey(ci => ci.CatalogBrandId); | ||
|
||
builder.HasOne(ci => ci.CatalogType) | ||
.WithMany() | ||
.HasForeignKey(ci => ci.CatalogTypeId); | ||
} | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
src/Infrastructure/Data/Config/CatalogItemOrderedConfiguration.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,16 @@ | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.EntityFrameworkCore.Metadata.Builders; | ||
using Microsoft.eShopWeb.ApplicationCore.Entities.OrderAggregate; | ||
|
||
namespace Microsoft.eShopWeb.Infrastructure.Data.Config | ||
{ | ||
public class CatalogItemOrderedConfiguration : IEntityTypeConfiguration<CatalogItemOrdered> | ||
{ | ||
public void Configure(EntityTypeBuilder<CatalogItemOrdered> builder) | ||
{ | ||
builder.Property(cio => cio.ProductName) | ||
.HasMaxLength(50) | ||
.IsRequired(); | ||
} | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
src/Infrastructure/Data/Config/CatalogTypeConfiguration.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,22 @@ | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.EntityFrameworkCore.Metadata.Builders; | ||
using Microsoft.eShopWeb.ApplicationCore.Entities; | ||
|
||
namespace Microsoft.eShopWeb.Infrastructure.Data.Config | ||
{ | ||
public class CatalogTypeConfiguration : IEntityTypeConfiguration<CatalogType> | ||
{ | ||
public void Configure(EntityTypeBuilder<CatalogType> builder) | ||
{ | ||
builder.HasKey(ci => ci.Id); | ||
|
||
builder.Property(ci => ci.Id) | ||
.ForSqlServerUseSequenceHiLo("catalog_type_hilo") | ||
.IsRequired(); | ||
|
||
builder.Property(cb => cb.Type) | ||
.IsRequired() | ||
.HasMaxLength(100); | ||
} | ||
} | ||
} |
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 Microsoft.EntityFrameworkCore; | ||
using Microsoft.EntityFrameworkCore.Metadata.Builders; | ||
using Microsoft.eShopWeb.ApplicationCore.Entities.OrderAggregate; | ||
|
||
namespace Microsoft.eShopWeb.Infrastructure.Data.Config | ||
{ | ||
public class OrderConfiguration : IEntityTypeConfiguration<Order> | ||
{ | ||
public void Configure(EntityTypeBuilder<Order> builder) | ||
{ | ||
var navigation = builder.Metadata.FindNavigation(nameof(Order.OrderItems)); | ||
|
||
navigation.SetPropertyAccessMode(PropertyAccessMode.Field); | ||
|
||
builder.OwnsOne(o => o.ShipToAddress); | ||
} | ||
} | ||
} |
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 Microsoft.EntityFrameworkCore; | ||
using Microsoft.EntityFrameworkCore.Metadata.Builders; | ||
using Microsoft.eShopWeb.ApplicationCore.Entities.OrderAggregate; | ||
|
||
namespace Microsoft.eShopWeb.Infrastructure.Data.Config | ||
{ | ||
public class OrderItemConfiguration : IEntityTypeConfiguration<OrderItem> | ||
{ | ||
public void Configure(EntityTypeBuilder<OrderItem> builder) | ||
{ | ||
builder.OwnsOne(i => i.ItemOrdered); | ||
|
||
builder.Property(oi => oi.UnitPrice) | ||
.IsRequired(true) | ||
.HasColumnType("decimal(18,2)"); | ||
} | ||
} | ||
} |
Oops, something went wrong.