PIbd-22-Ismailov_SUBD/BlogDataModels/BlogDatabaseImplement/BlogDatabase.cs
2023-05-18 21:34:36 +04:00

36 lines
1.0 KiB
C#

using Microsoft.EntityFrameworkCore;
using BlogDatabaseImplement.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel;
namespace BlogDatabaseImplement
{
public class BlogDatabase : DbContext
{
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
if (optionsBuilder.IsConfigured == false)
{
optionsBuilder.UseNpgsql(@"
Host=localhost;
Port=5432;
Database=BlogDB;
Username=postgres;
Password=postgres");
}
base.OnConfiguring(optionsBuilder);
}
public virtual DbSet<Tag> Tags { set; get; }
public virtual DbSet<User> Users { set; get; }
public virtual DbSet<News> News { set; get; }
public virtual DbSet<Comment> Comments { set; get; }
public virtual DbSet<NewsTag> NewsTags { set; get; }
}
}