Создал файл с точкой подключения БД, установил необходимые зависимости

This commit is contained in:
Никита Потапов 2024-04-28 11:41:30 +04:00
parent 165a8ff96c
commit 8aaa37df75
2 changed files with 23 additions and 1 deletions

View File

@ -0,0 +1,17 @@
using Microsoft.EntityFrameworkCore;
namespace SecuritySystemDatabaseImplement
{
public class SecuritySystemDatabase : DbContext
{
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
if (optionsBuilder.IsConfigured == false)
{
optionsBuilder.UseSqlServer(@"Data Source=localhost\SQLEXPRESS;Initial Catalog=PolyclinicDatabase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
}
base.OnConfiguring(optionsBuilder);
}
//public virtual DbSet<Component> Components { set; get; }
}
}

View File

@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
@ -11,4 +11,9 @@
<Folder Include="Models\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.16" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.16" />
</ItemGroup>
</Project>