using Microsoft.EntityFrameworkCore; using presence.data.RemoteData.RemoteDataBase.DAO; using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; namespace presence.data.RemoteData.RemoteDataBase { public class RemoteDataBaseContext: DbContext { protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder){ optionsBuilder.UseNpgsql("Host=localhost; Port=5432; Database=presencedb; Username=postgres; Password=123"); } protected override void OnModelCreating(ModelBuilder modelBuilder) { modelBuilder.Entity().HasKey(group => group.Id); modelBuilder.Entity().Property(group => group.Id).ValueGeneratedOnAdd(); modelBuilder.Entity().HasKey(user => user.UserId); modelBuilder.Entity().Property(user => user.UserId).ValueGeneratedOnAdd(); modelBuilder.Entity().HasKey(presence =>presence.PresenceId); modelBuilder.Entity().Property(presence=>presence.PresenceId).ValueGeneratedOnAdd(); modelBuilder.Entity() .HasOne(presence => presence.User) .WithMany(user => user.Presences) .HasForeignKey(presence => presence.UserId); } public DbSet Groups { get; set; } public DbSet Users { get; set; } public DbSet Presences { get; set; } } }