diff --git a/CarService/CarService.sln b/CarService/CarService.sln index f82b23c..3126932 100644 --- a/CarService/CarService.sln +++ b/CarService/CarService.sln @@ -5,6 +5,8 @@ VisualStudioVersion = 17.6.33717.318 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleMainApp", "ConsoleMainApp\ConsoleMainApp.csproj", "{4121A5A1-68DA-4F32-B8D6-EE5BA60C6890}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CarServiceDataBaseImplements", "CarServiceDataBaseImplements\CarServiceDataBaseImplements.csproj", "{48D159D4-7150-417E-BBE9-2B636E1EAFFB}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -15,6 +17,10 @@ Global {4121A5A1-68DA-4F32-B8D6-EE5BA60C6890}.Debug|Any CPU.Build.0 = Debug|Any CPU {4121A5A1-68DA-4F32-B8D6-EE5BA60C6890}.Release|Any CPU.ActiveCfg = Release|Any CPU {4121A5A1-68DA-4F32-B8D6-EE5BA60C6890}.Release|Any CPU.Build.0 = Release|Any CPU + {48D159D4-7150-417E-BBE9-2B636E1EAFFB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {48D159D4-7150-417E-BBE9-2B636E1EAFFB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {48D159D4-7150-417E-BBE9-2B636E1EAFFB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {48D159D4-7150-417E-BBE9-2B636E1EAFFB}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/CarService/CarServiceDataBaseImplements/CarServiceDataBase.cs b/CarService/CarServiceDataBaseImplements/CarServiceDataBase.cs new file mode 100644 index 0000000..75ce2cf --- /dev/null +++ b/CarService/CarServiceDataBaseImplements/CarServiceDataBase.cs @@ -0,0 +1,22 @@ +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CarServiceDataBaseImplements +{ + public class CarServiceDataBase : DbContext + { + protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) + { + if(optionsBuilder.IsConfigured == false) + { + optionsBuilder.UseNpgsql("Host=localhost;Database=CarServiceDataBase;Username=postgres;Password=postgres"); + } + base.OnConfiguring(optionsBuilder); + } + + } +} diff --git a/CarService/CarServiceDataBaseImplements/CarServiceDataBaseImplements.csproj b/CarService/CarServiceDataBaseImplements/CarServiceDataBaseImplements.csproj new file mode 100644 index 0000000..7003c17 --- /dev/null +++ b/CarService/CarServiceDataBaseImplements/CarServiceDataBaseImplements.csproj @@ -0,0 +1,14 @@ + + + + net7.0 + enable + enable + + + + + + + + diff --git a/CarService/ConsoleMainApp/ConsoleMainApp.csproj b/CarService/ConsoleMainApp/ConsoleMainApp.csproj index f02677b..6b27552 100644 --- a/CarService/ConsoleMainApp/ConsoleMainApp.csproj +++ b/CarService/ConsoleMainApp/ConsoleMainApp.csproj @@ -7,4 +7,12 @@ enable + + + + + + + + diff --git a/CarService/ConsoleMainApp/Program.cs b/CarService/ConsoleMainApp/Program.cs index 655d3c1..3ee824f 100644 --- a/CarService/ConsoleMainApp/Program.cs +++ b/CarService/ConsoleMainApp/Program.cs @@ -1,10 +1,17 @@ -namespace ConsoleMainApp +using CarServiceDataBaseImplements; +using Microsoft.EntityFrameworkCore; +using Npgsql; + +namespace ConsoleMainApp { internal class Program { + static void Main(string[] args) { - Console.WriteLine("Hello, World!"); + using var context = new CarServiceDataBase(); + context.Database.OpenConnection(); + context.Database.CloseConnection(); } } } \ No newline at end of file