diff --git a/PuferFishContracts/PuferFishContracts/Infrastructure/IConfigurationDatabase.cs b/PuferFishContracts/PuferFishContracts/Infrastructure/IConfigurationDatabase.cs
new file mode 100644
index 0000000..3407673
--- /dev/null
+++ b/PuferFishContracts/PuferFishContracts/Infrastructure/IConfigurationDatabase.cs
@@ -0,0 +1,12 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PuferFishContracts.Infrastructure;
+
+public interface IConfigurationDatabase
+{
+ string ConnectionString { get; }
+}
diff --git a/PuferFishContracts/PuferFishDataBase/PuferFishDataBase.csproj b/PuferFishContracts/PuferFishDataBase/PuferFishDataBase.csproj
index 0adc9e6..d38afa4 100644
--- a/PuferFishContracts/PuferFishDataBase/PuferFishDataBase.csproj
+++ b/PuferFishContracts/PuferFishDataBase/PuferFishDataBase.csproj
@@ -6,6 +6,11 @@
enable
+
+
+
+
+
diff --git a/PuferFishContracts/PuferFishDataBase/PuferFishDbContext.cs b/PuferFishContracts/PuferFishDataBase/PuferFishDbContext.cs
new file mode 100644
index 0000000..82d68e4
--- /dev/null
+++ b/PuferFishContracts/PuferFishDataBase/PuferFishDbContext.cs
@@ -0,0 +1,51 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Microsoft.EntityFrameworkCore;
+using PuferFishContracts.Infrastructure;
+using PuferFishDataBase.Models;
+
+namespace PuferFishDataBase;
+
+internal class PuferFishDbContext(IConfigurationDatabase configurationDatabase) : DbContext
+{
+ private readonly IConfigurationDatabase? _configurationDatabase = configurationDatabase;
+ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
+ {
+ optionsBuilder.UseNpgsql(_configurationDatabase?.ConnectionString, o => o.SetPostgresVersion(12, 2));
+ base.OnConfiguring(optionsBuilder);
+ }
+
+ protected override void OnModelCreating(ModelBuilder modelBuilder)
+ {
+ base.OnModelCreating(modelBuilder);
+ modelBuilder.Entity().HasIndex(x => x.PhoneNumber).IsUnique();
+ modelBuilder.Entity()
+ .HasIndex(e => new { e.PostName, e.IsActual })
+ .IsUnique()
+ .HasFilter($"\"{nameof(Post.IsActual)}\" = TRUE");
+ modelBuilder.Entity()
+ .HasIndex(e => new { e.PostId, e.IsActual })
+ .IsUnique()
+ .HasFilter($"\"{nameof(Post.IsActual)}\" = TRUE");
+ modelBuilder.Entity()
+ .HasIndex(x => new { x.ProductName, x.IsDeleted })
+ .IsUnique()
+ .HasFilter($"\"{nameof(Product.IsDeleted)}\" = FALSE");
+ modelBuilder.Entity().HasKey(x => new {
+ x.SaleId,
+ x.ProductId
+ });
+ }
+
+ public DbSet Buyers { get; set; }
+ public DbSet Posts { get; set; }
+ public DbSet Products { get; set; }
+ public DbSet ProductHistories { get; set; }
+ public DbSet Pointss { get; set; }
+ public DbSet Sales { get; set; }
+ public DbSet SaleProducts { get; set; }
+ public DbSet Workers { get; set; }
+}