| | | 1 | | using Microsoft.EntityFrameworkCore; |
| | | 2 | | using OzonDomains.Models.OzonApi; |
| | | 3 | | |
| | | 4 | | namespace OzonRepositories.Context; |
| | | 5 | | |
| | | 6 | | /// <summary>Read-only контекст каталога Ozon Seller (БД OzonApi на prod-сервере).</summary> |
| | | 7 | | public class OzonApiContext : DbContext |
| | | 8 | | { |
| | | 9 | | public OzonApiContext(DbContextOptions<OzonApiContext> options) |
| | 3 | 10 | | : base(options) |
| | | 11 | | { |
| | 3 | 12 | | } |
| | | 13 | | |
| | 5 | 14 | | public DbSet<OzonProduct> OzonProducts { get; set; } = null!; |
| | | 15 | | |
| | | 16 | | protected override void OnModelCreating(ModelBuilder modelBuilder) |
| | | 17 | | { |
| | 1 | 18 | | base.OnModelCreating(modelBuilder); |
| | | 19 | | |
| | 1 | 20 | | modelBuilder.Entity<OzonProduct>(entity => |
| | 1 | 21 | | { |
| | 1 | 22 | | entity.HasIndex(e => new { e.AccountId, e.OfferId }) |
| | 1 | 23 | | .IsUnique() |
| | 1 | 24 | | .HasDatabaseName("uq_account_offer"); |
| | 1 | 25 | | |
| | 1 | 26 | | entity.HasIndex(e => e.AccountId) |
| | 1 | 27 | | .HasDatabaseName("idx_account_id"); |
| | 1 | 28 | | |
| | 1 | 29 | | entity.HasIndex(e => e.OfferId) |
| | 1 | 30 | | .HasDatabaseName("idx_offer_id"); |
| | 1 | 31 | | |
| | 1 | 32 | | entity.HasIndex(e => e.PriceIndex) |
| | 1 | 33 | | .HasDatabaseName("idx_price_index"); |
| | 2 | 34 | | }); |
| | 1 | 35 | | } |
| | | 36 | | } |