26 lines
797 B
C#
26 lines
797 B
C#
using Bunny.Dao.Models.System;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace Bunny.Common.EFCore;
|
|
|
|
public class EfCoreContext : DbContext
|
|
{
|
|
public EfCoreContext()
|
|
{
|
|
DbPath = @"D:\MyFolder\Bunny\Bunny-cli\Template\CSharp\CSharp-Single-EFCore\Bunny.WebApi\Database\bunny.db";
|
|
// var dataBaseConnection = AppSettings.GetAppConfig<string>("DataBase:DataBaseConnection");
|
|
// DbPath = dataBaseConnection;
|
|
}
|
|
|
|
public DbSet<Blog> Blogs { get; set; }
|
|
public DbSet<Post> Posts { get; set; }
|
|
public DbSet<Product> Products { get; set; }
|
|
public DbSet<User> Users { get; set; }
|
|
|
|
public string DbPath { get; }
|
|
|
|
protected override void OnConfiguring(DbContextOptionsBuilder options)
|
|
{
|
|
options.UseSqlite($"Data Source={DbPath}");
|
|
}
|
|
} |