From a794921f82895465c5de902594fe5d5b5da336a9 Mon Sep 17 00:00:00 2001 From: Oleg Shabunov Date: Wed, 17 Apr 2024 17:38:54 +0400 Subject: [PATCH] create DatabaseImplement project --- ComputerShop.sln | 6 ++++++ .../ComputerShopDatabase.cs | 20 +++++++++++++++++++ .../ComputerShopDatabaseImplement.csproj | 18 +++++++++++++++++ 3 files changed, 44 insertions(+) create mode 100644 ComputerShopDatabaseImplement/ComputerShopDatabase.cs create mode 100644 ComputerShopDatabaseImplement/ComputerShopDatabaseImplement.csproj diff --git a/ComputerShop.sln b/ComputerShop.sln index db205e0..692a628 100644 --- a/ComputerShop.sln +++ b/ComputerShop.sln @@ -11,6 +11,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ComputerShopContracts", "Co EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ComputerShopBusinessLogic", "ComputerShopBusinessLogic\ComputerShopBusinessLogic.csproj", "{82FCBA71-AC54-45C8-9B21-BCB3DF6E085B}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ComputerShopDatabaseImplement", "ComputerShopDatabaseImplement\ComputerShopDatabaseImplement.csproj", "{CDE4C963-67B5-47A6-A394-901E95EA40F7}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -33,6 +35,10 @@ Global {82FCBA71-AC54-45C8-9B21-BCB3DF6E085B}.Debug|Any CPU.Build.0 = Debug|Any CPU {82FCBA71-AC54-45C8-9B21-BCB3DF6E085B}.Release|Any CPU.ActiveCfg = Release|Any CPU {82FCBA71-AC54-45C8-9B21-BCB3DF6E085B}.Release|Any CPU.Build.0 = Release|Any CPU + {CDE4C963-67B5-47A6-A394-901E95EA40F7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CDE4C963-67B5-47A6-A394-901E95EA40F7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CDE4C963-67B5-47A6-A394-901E95EA40F7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CDE4C963-67B5-47A6-A394-901E95EA40F7}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/ComputerShopDatabaseImplement/ComputerShopDatabase.cs b/ComputerShopDatabaseImplement/ComputerShopDatabase.cs new file mode 100644 index 0000000..1cf7b34 --- /dev/null +++ b/ComputerShopDatabaseImplement/ComputerShopDatabase.cs @@ -0,0 +1,20 @@ +using Microsoft.EntityFrameworkCore; + +namespace ComputerShopDatabaseImplement +{ + public class ComputerShopDatabase : DbContext + { + protected override void OnConfiguring(DbContextOptionsBuilder OptionsBuilder) + { + if (!OptionsBuilder.IsConfigured) + { + OptionsBuilder.UseNpgsql(@"Host=localhost;Database=ComputerShop;Username=postgres;Password=admin"); + } + + base.OnConfiguring(OptionsBuilder); + + AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true); + AppContext.SetSwitch("Npgsql.DisableDateTimeInfinityConversions", true); + } + } +} diff --git a/ComputerShopDatabaseImplement/ComputerShopDatabaseImplement.csproj b/ComputerShopDatabaseImplement/ComputerShopDatabaseImplement.csproj new file mode 100644 index 0000000..1eeb4a1 --- /dev/null +++ b/ComputerShopDatabaseImplement/ComputerShopDatabaseImplement.csproj @@ -0,0 +1,18 @@ + + + + net6.0 + enable + enable + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + +