slarny4/Demo1/Data/RemoteData/RemoteDataBase/RemoteDatabaseContext.cs

26 lines
1013 B
C#
Raw Normal View History

2024-11-25 04:33:26 +00:00
using Microsoft.EntityFrameworkCore;
using Demo.Data.RemoteData.RemoteDataBase.DAO; // Используйте правильное пространство имен
2024-10-28 12:42:04 +00:00
2024-11-25 04:33:26 +00:00
namespace Demo.Data.RemoteData.RemoteDataBase
2024-10-28 12:42:04 +00:00
{
2024-11-25 04:33:26 +00:00
public class RemoteDatabaseContext : DbContext
2024-10-28 12:42:04 +00:00
{
2024-11-25 04:33:26 +00:00
public DbSet<User> Users { get; set; }
public DbSet<Group> Groups { get; set; }
public DbSet<Presence> Presence { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
2024-10-28 12:42:04 +00:00
{
2024-11-25 04:33:26 +00:00
optionsBuilder.UseNpgsql("Host=45.67.56.214;Port=5421;Username=user5;Database=user5;Password=EtEJqhsf");
2024-10-28 12:42:04 +00:00
}
2024-11-14 11:24:07 +00:00
2024-11-25 04:33:26 +00:00
protected override void OnModelCreating(ModelBuilder modelBuilder)
2024-11-14 11:24:07 +00:00
{
2024-11-25 04:33:26 +00:00
modelBuilder.Entity<Presence>()
.HasKey(p => p.Id); // Указание первичного ключа
modelBuilder.Entity<Group>()
.HasKey(g => g.Id); // Указание первичного ключа
}
2024-11-14 11:24:07 +00:00
}
2024-11-25 04:33:26 +00:00
}