AugusteVN.Modules.Commerce.Database
1.1.1
dotnet add package AugusteVN.Modules.Commerce.Database --version 1.1.1
NuGet\Install-Package AugusteVN.Modules.Commerce.Database -Version 1.1.1
<PackageReference Include="AugusteVN.Modules.Commerce.Database" Version="1.1.1" />
<PackageVersion Include="AugusteVN.Modules.Commerce.Database" Version="1.1.1" />
<PackageReference Include="AugusteVN.Modules.Commerce.Database" />
paket add AugusteVN.Modules.Commerce.Database --version 1.1.1
#r "nuget: AugusteVN.Modules.Commerce.Database, 1.1.1"
#:package AugusteVN.Modules.Commerce.Database@1.1.1
#addin nuget:?package=AugusteVN.Modules.Commerce.Database&version=1.1.1
#tool nuget:?package=AugusteVN.Modules.Commerce.Database&version=1.1.1
AugusteVN.Modules.Commerce.Database
EF Core CommerceDbContext with entities for products, shop orders, and order line items.
Part of the AugusteVN Modules collection.
DbContext
ICommerceDbContext
Interface exposing DbSet properties for testability and loose coupling. Implements ISaveChangesAsync.
CommerceDbContext
Concrete EF Core DbContext targeting SQL Server with no-tracking query behavior.
DbSets:
| DbSet | Entity | Description |
|---|---|---|
Products |
Product |
Product catalog |
ShopOrders |
ShopOrder |
Customer orders |
ShopOrderProducts |
ShopOrderProduct |
Order line items (join entity) |
ProductAttachments |
AttachmentEntity |
File attachments for digital products |
Configuration:
- Connection string:
DefaultConnection - Migrations assembly: Commerce.Database project
- Migration history table:
Commerce_EFMigrationHistory - Default query tracking:
NoTracking - Auto-auditing:
CreatedBy,CreatedAt,LastModifiedBy,LastModifiedAtviaAuditableEntitybase
Entities
Product (extends AuditableEntity)
| Property | Type | Description |
|---|---|---|
Id |
Guid |
Primary key (from Entity) |
Title |
string |
Display title |
CoverPhotoUrl |
string |
Cover image URL |
BodyAsMarkdown |
string |
Description in Markdown |
BodyAsHtml |
string |
Description in HTML |
Slug |
string |
URL-friendly slug |
IsAvailable |
bool |
Available for purchase |
IsPinned |
bool |
Pinned to top of listings |
AmountInStock |
int |
Stock quantity |
Price |
double |
Regular price |
Discounted |
Discounted |
Owned type: discounted price and expiration |
IsDigital |
bool |
Digital product flag |
IsLeadMagnet |
bool |
Free lead magnet flag |
Downloadable |
DownloadableEntity? |
Owned type: file attachment info |
ShopOrder (extends TrackingBaseEntity)
| Property | Type | Default | Description |
|---|---|---|---|
Id |
Guid |
— | Primary key |
Email |
string |
— | Customer email |
Address |
string? |
— | Shipping address |
Products |
List<ShopOrderProduct> |
— | Navigation: line items |
PaymentRefId |
Guid? |
— | Payment reference |
Status |
string |
ShopOrderStatuses.Pending |
Order lifecycle status |
TotalPrice |
double? |
— | Calculated total |
ShopOrderProduct (extends AuditableEntity)
| Property | Type | Description |
|---|---|---|
Id |
Guid |
Primary key |
Quantity |
int |
Ordered quantity |
ProductId |
Guid |
Foreign key to Product |
Product |
Product |
Navigation: product |
Title |
string |
Product title snapshot |
ShopOrderId |
Guid |
Foreign key to ShopOrder |
ShopOrder |
ShopOrder |
Navigation: parent order |
Owned Types
| Type | Parent Entity | Properties |
|---|---|---|
Discounted |
Product |
Price (double), ExpiresAt (DateTime?) |
DownloadableEntity |
Product |
(from AugusteVN._Shared.Contracts.Downloadable) |
Extension Method
AddCommerceDbContext
public static void AddCommerceDbContext(this IServiceCollection services, IConfiguration configuration)
Registers ICommerceDbContext / CommerceDbContext with SQL Server, no-tracking queries, and a dedicated migration history table.
Registration
// Program.cs
builder.Services.AddCommerceDbContext(builder.Configuration);
Migrations
# Create migration
dotnet ef migrations add <MigrationName> `
--project ./_Modules/Commerce/Commerce.Database `
--startup-project <YourStartupProject> `
--context CommerceDbContext
# Apply migrations
dotnet ef database update `
--project ./_Modules/Commerce/Commerce.Database `
--startup-project <YourStartupProject> `
--context CommerceDbContext
Installation
dotnet add package AugusteVN.Modules.Commerce.Database
Dependencies
AugusteVN.Database.EFCoreAugusteVN.Database.Entities- AugusteVN.Modules.Commerce._Shared
Links
- Commerce module overview
- Commerce._Shared
- Commerce.Api
- Commerce.Features
- Commerce.Templates
- Commerce._Shared.Spa
Merged Domain Documentation
AugusteVN.Modules.Commerce.Database
Domain entities and shared interfaces for commerce — defines the ICommerceDbContext contract and all entity types used by both the EfCore persistence layer.
Entities
Product (extends AuditableEntity)
| Property | Type | Description |
|---|---|---|
Id |
Guid |
Primary key (inherited from Entity) |
Title |
string |
Display title |
CoverPhotoUrl |
string |
Cover image URL |
BodyAsMarkdown |
string |
Description in Markdown |
BodyAsHtml |
string |
Description in HTML |
Slug |
string |
URL-friendly slug |
IsAvailable |
bool |
Available for purchase |
AmountInStock |
int |
Stock quantity |
IsPinned |
bool |
Pinned to top of listings |
Price |
double |
Regular price |
Discounted |
Discounted |
Owned type: discounted price and expiration |
IsDigital |
bool |
Digital product flag |
IsLeadMagnet |
bool |
Free lead magnet flag |
Downloadable |
DownloadableEntity? |
Associated file download |
Discounted (owned type)
| Property | Type | Description |
|---|---|---|
Price |
double |
Discounted price |
ExpiresAt |
DateTime? |
Discount expiration date |
ShopOrder (extends TrackingBaseEntity)
| Property | Type | Default | Description |
|---|---|---|---|
Id |
Guid |
— | Primary key |
Email |
string |
— | Customer email |
Address |
string? |
— | Shipping address |
Products |
List<ShopOrderProduct> |
— | Navigation: line items |
PaymentRefId |
Guid? |
— | Payment reference |
Status |
string |
ShopOrderStatuses.Pending |
Order lifecycle status |
TotalPrice |
double? |
— | Calculated total |
ShopOrderProduct (extends AuditableEntity)
| Property | Type | Description |
|---|---|---|
Id |
Guid |
Primary key |
Quantity |
int |
Ordered quantity |
ProductId |
Guid |
Foreign key to Product |
Product |
Product |
Navigation: product |
Title |
string |
Product title snapshot |
ShopOrderId |
Guid |
Foreign key to ShopOrder |
ShopOrder |
ShopOrder |
Navigation: parent order |
Interface
ICommerceDbContext
public interface ICommerceDbContext
{
DbSet<Product> Products { get; set; }
DbSet<ShopOrder> ShopOrders { get; set; }
DbSet<ShopOrderProduct> ShopOrderProducts { get; set; }
DbSet<AttachmentEntity> ProductAttachments { get; set; }
Task<int> SaveChangesAsync(CancellationToken cancellationToken = default);
}
Provider-agnostic contract implemented by both CommerceEfCoreDbContext and CommerceDbContext.
Dependencies
AugusteVN._Shared.ContractsAugusteVN.Database.EntitiesAugusteVN.Modules.Commerce._Shared
Installation
dotnet add package AugusteVN.Modules.Commerce.Database
Full Documentation
See the Commerce Module README for complete documentation.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- AugusteVN.Database.EFCore (>= 1.1.4)
- AugusteVN.Database.Entities (>= 1.1.5)
- AugusteVN.Modules.Commerce._Shared (>= 1.0.8)
- Microsoft.EntityFrameworkCore (>= 10.0.0)
- Microsoft.EntityFrameworkCore.SqlServer (>= 10.0.0)
- Microsoft.Extensions.Configuration.Abstractions (>= 10.0.0)
- Npgsql.EntityFrameworkCore.PostgreSQL (>= 10.0.0)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on AugusteVN.Modules.Commerce.Database:
| Package | Downloads |
|---|---|
|
AugusteVN.Modules.Commerce.Api
Minimal API endpoints for products and shop orders |
|
|
AugusteVN.Modules.Commerce.Features
CQRS handlers for product and shop order operations |
GitHub repositories
This package is not used by any popular GitHub repositories.