ShopPlatform.Web
1.0.0.0
농산물, 소프트웨어 라이선스와 개발 용역을 직접 판매하는 CodeMaru 직영 쇼핑몰입니다.
Toggle main menu visibility
로딩중...
검색중...
일치하는것 없음
TenantDbContext.cs
이 파일의 문서화 페이지로 가기
1
using
Microsoft.EntityFrameworkCore;
2
using
ShopPlatform.Models
;
3
4
namespace
ShopPlatform.Data
;
5
14
public
sealed
class
TenantDbContext
: DbContext
15
{
32
public
TenantDbContext
(DbContextOptions<TenantDbContext> options) : base(options) { }
33
42
public
DbSet<Product>
Products
=> Set<Product>();
51
public
DbSet<Order>
Orders
=> Set<Order>();
60
public
DbSet<OrderLine>
OrderLines
=> Set<OrderLine>();
69
public
DbSet<ShopUser>
Users
=> Set<ShopUser>();
70
87
protected
override
void
OnModelCreating
(ModelBuilder mb)
88
{
89
mb.Entity<
Product
>(e =>
90
{
91
e.HasKey(p => p.Id);
92
e.Property(p => p.Price).HasColumnType(
"TEXT"
);
// SQLite decimal 호환
93
});
94
95
mb.Entity<
Order
>(e =>
96
{
97
e.HasKey(o => o.Id);
98
e.Property(o => o.TotalAmount).HasColumnType(
"TEXT"
);
99
e.HasMany(o => o.Lines)
100
.WithOne()
101
.HasForeignKey(l => l.OrderId)
102
.OnDelete(DeleteBehavior.Cascade);
103
});
104
105
mb.Entity<
OrderLine
>(e =>
106
{
107
e.HasKey(l => l.Id);
108
e.Property(l => l.UnitPrice).HasColumnType(
"TEXT"
);
109
e.Ignore(l => l.Subtotal);
110
});
111
112
mb.Entity<
ShopUser
>(e =>
113
{
114
e.HasKey(u => u.Id);
115
e.HasIndex(u => u.Email).IsUnique();
116
});
117
}
118
}
ShopPlatform.Data
Definition
ShopSeeder.cs:4
ShopPlatform.Models
Definition
CartItem.cs:1
ShopPlatform.Data.TenantDbContext.OrderLines
DbSet< OrderLine > OrderLines
Definition
TenantDbContext.cs:60
ShopPlatform.Data.TenantDbContext.Users
DbSet< ShopUser > Users
Definition
TenantDbContext.cs:69
ShopPlatform.Data.TenantDbContext.Products
DbSet< Product > Products
Definition
TenantDbContext.cs:42
ShopPlatform.Data.TenantDbContext.OnModelCreating
override void OnModelCreating(ModelBuilder mb)
Definition
TenantDbContext.cs:87
ShopPlatform.Data.TenantDbContext.Orders
DbSet< Order > Orders
Definition
TenantDbContext.cs:51
ShopPlatform.Data.TenantDbContext.TenantDbContext
TenantDbContext(DbContextOptions< TenantDbContext > options)
Definition
TenantDbContext.cs:32
ShopPlatform.Models.Order
Definition
Order.cs:12
ShopPlatform.Models.OrderLine
Definition
Order.cs:123
ShopPlatform.Models.Product
Definition
Product.cs:12
ShopPlatform.Models.ShopUser
Definition
ShopUser.cs:12
Data
TenantDbContext.cs
다음에 의해 생성됨 :
1.17.0