diff --git a/TransportCompany/TransportCompany/App.config b/TransportCompany/TransportCompany/App.config new file mode 100644 index 0000000..3cd7446 --- /dev/null +++ b/TransportCompany/TransportCompany/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/TransportCompany/TransportCompanyDatabaseImplements/ElegevContext.cs b/TransportCompany/TransportCompanyDatabaseImplements/ElegevContext.cs index ec57a2c..e1cfe71 100644 --- a/TransportCompany/TransportCompanyDatabaseImplements/ElegevContext.cs +++ b/TransportCompany/TransportCompanyDatabaseImplements/ElegevContext.cs @@ -1,6 +1,9 @@ using System; using System.Collections.Generic; +using System.Configuration; using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Internal; +using Microsoft.Extensions.Options; using TransportCompanyDatabaseImplements.Models; namespace TransportCompanyDatabaseImplements; @@ -26,9 +29,11 @@ public partial class ElegevContext : DbContext public virtual DbSet TypeTransportations { get; set; } + string dbName = ConfigurationManager.AppSettings["connectToDb"]; + 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.101;Port=6000;Database=elegev;Username=elegev;Password=user"); + => optionsBuilder.UseNpgsql(dbName); protected override void OnModelCreating(ModelBuilder modelBuilder) { diff --git a/TransportCompany/TransportCompanyDatabaseImplements/TransportCompanyDatabaseImplements.csproj b/TransportCompany/TransportCompanyDatabaseImplements/TransportCompanyDatabaseImplements.csproj index 07207df..d58e65a 100644 --- a/TransportCompany/TransportCompanyDatabaseImplements/TransportCompanyDatabaseImplements.csproj +++ b/TransportCompany/TransportCompanyDatabaseImplements/TransportCompanyDatabaseImplements.csproj @@ -16,6 +16,7 @@ runtime; build; native; contentfiles; analyzers; buildtransitive +