Добавление конфигурации
This commit is contained in:
parent
2f1dbeee40
commit
2d9db74bce
@ -14,6 +14,7 @@
|
|||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="7.0.3" />
|
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="7.0.3" />
|
||||||
|
<PackageReference Include="System.Configuration.ConfigurationManager" Version="7.0.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using System.Configuration;
|
||||||
|
|
||||||
namespace BeautySaloonDatabaseImplement;
|
namespace BeautySaloonDatabaseImplement;
|
||||||
|
|
||||||
@ -26,9 +27,10 @@ public partial class NewdbContext : DbContext
|
|||||||
public virtual DbSet<ServiceOrder> ServiceOrders { get; set; }
|
public virtual DbSet<ServiceOrder> ServiceOrders { get; set; }
|
||||||
|
|
||||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||||
#warning To protect potentially sensitive information in your connection string, you should move it out of source code. You can avoid scaffolding the connection string by using the Name= syntax to read it from configuration - see https://go.microsoft.com/fwlink/?linkid=2131148. For more guidance on storing connection strings, see http://go.microsoft.com/fwlink/?LinkId=723263.
|
{
|
||||||
=> optionsBuilder.UseNpgsql("Host=192.168.56.102;Port=5432;Database=newdb;Username=username123;Password=12345");
|
string connectString = ConfigurationManager.AppSettings["connect"]!;
|
||||||
|
optionsBuilder.UseNpgsql(connectString);
|
||||||
|
}
|
||||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||||
{
|
{
|
||||||
modelBuilder.Entity<Client>(entity =>
|
modelBuilder.Entity<Client>(entity =>
|
||||||
|
6
BeautySaloon/BeautySaloonView/App.config
Normal file
6
BeautySaloon/BeautySaloonView/App.config
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<configuration>
|
||||||
|
<appSettings>
|
||||||
|
<add key="connect" value="Host=192.168.56.102;Port=5432;Database=newdb;Username=username123;Password=12345"/>
|
||||||
|
</appSettings>
|
||||||
|
</configuration>
|
@ -19,6 +19,7 @@
|
|||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
|
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
|
||||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="7.0.3" />
|
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="7.0.3" />
|
||||||
|
<PackageReference Include="System.Configuration.ConfigurationManager" Version="7.0.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
Loading…
Reference in New Issue
Block a user