Не ну вроде даже работает :)
This commit is contained in:
parent
bf77b92a4b
commit
9c00ec5694
6
TransportCompany/TransportCompany/App.config
Normal file
6
TransportCompany/TransportCompany/App.config
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<configuration>
|
||||||
|
<appSettings>
|
||||||
|
<add key="connectToDb" value="Host=192.168.56.101;Port=6000;Database=elegev;Username=elegev;Password=user"/>
|
||||||
|
</appSettings>
|
||||||
|
</configuration>
|
@ -1,6 +1,9 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Configuration;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Metadata.Internal;
|
||||||
|
using Microsoft.Extensions.Options;
|
||||||
using TransportCompanyDatabaseImplements.Models;
|
using TransportCompanyDatabaseImplements.Models;
|
||||||
|
|
||||||
namespace TransportCompanyDatabaseImplements;
|
namespace TransportCompanyDatabaseImplements;
|
||||||
@ -26,9 +29,11 @@ public partial class ElegevContext : DbContext
|
|||||||
|
|
||||||
public virtual DbSet<TypeTransportation> TypeTransportations { get; set; }
|
public virtual DbSet<TypeTransportation> TypeTransportations { get; set; }
|
||||||
|
|
||||||
|
string dbName = ConfigurationManager.AppSettings["connectToDb"];
|
||||||
|
|
||||||
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.
|
#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.101;Port=6000;Database=elegev;Username=elegev;Password=user");
|
=> optionsBuilder.UseNpgsql(dbName);
|
||||||
|
|
||||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||||
{
|
{
|
||||||
|
@ -16,6 +16,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>
|
||||||
|
Loading…
Reference in New Issue
Block a user