/
githubmirror
/
ydb-dotnet-sdk
Обзор
Документация
Войти
/
githubmirror
/
ydb-dotnet-sdk
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
examples/EntityFrameworkCore.Ydb.Samples/Database.Operations.Tutorial/HRContext.cs
38 строк
1 KB
Kirill Kurdyukov
feat: EF samples & refactoring (#430)
28 май 2025, 19:35
Не верифицирован
28 май 2025, 19:35
942ed4c
Код
Авторство
О чём код?
using EntityFrameworkCore.Ydb.Extensions; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Logging; namespace Database.Operations.Tutorial; public class HRContext : DbContext { public DbSet<Employee> Employees { get; set; } public DbSet<Department> Departments { get; set; } public DbSet<EmployeeProfile> EmployeeProfiles { get; set; } public DbSet<Skill> Skills { get; set; } public HRContext() { } public HRContext(DbContextOptions<HRContext> options) : base(options) { } protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { var configuration = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile("appsettings.json") .Build(); var connectionString = configuration.GetConnectionString("Local"); optionsBuilder.UseYdb(connectionString) .LogTo(Console.WriteLine, new[] { DbLoggerCategory.Database.Command.Name }, LogLevel.Information) .ConfigureWarnings(warnings => warnings.Ignore(RelationalEventId.PendingModelChangesWarning)) .EnableSensitiveDataLogging(); } }