iFactory.Godot/BITKit/Scripts/EntityFramework/SQLiteContext.cs

17 lines
526 B
C#
Raw Normal View History

2023-07-03 02:34:01 +08:00
using Microsoft.EntityFrameworkCore;
namespace BITKit;
public class SqlLiteContext<T> : DbContext where T : class
{
private const string _database = "Database";
public DbSet<T> context { get; private set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
PathHelper.GetFolderPath(_database);
var path = PathHelper.GetPath(_database, $"{typeof(T).Name}.db");
var sql = $"Data Source={path}";
BIT4Log.Log<T>($"已创建数据库链接:{path}");
optionsBuilder.UseSqlite(sql);
}
}