You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
621 B
23 lines
621 B
using Microsoft.EntityFrameworkCore;
|
|
using Tiobon.Core.DB;
|
|
|
|
namespace Tiobon.Core.DataAccess;
|
|
|
|
/// <summary>
|
|
/// 直接创建 Context
|
|
/// </summary>
|
|
public class ContextFactory
|
|
{
|
|
/// <summary>
|
|
/// 创建DbContext
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public static DataContext CreateContext()
|
|
{
|
|
var builder = new DbContextOptionsBuilder<DataContext>();
|
|
|
|
var mainConnetctDb = BaseDBConfig.MutiConnectionString.allDbs.Find(x => x.ConnId == MainDb.CurrentDbConnId);
|
|
builder.UseSqlServer(mainConnetctDb.Connection);
|
|
return new DataContext(builder.Options);
|
|
}
|
|
}
|
|
|