current
This commit is contained in:
parent
796faede69
commit
c5041e5fed
@ -16,9 +16,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Contracts", "Contracts\Cont
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Services", "Services\Services.csproj", "{4CCFADCD-9E80-4B66-A6D8-B6FC5490A0C0}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Presentation", "Presentation\Presentation.csproj", "{9359CCCA-F725-462F-AACD-8FCAE5C907E5}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Presentation", "Presentation\Presentation.csproj", "{9359CCCA-F725-462F-AACD-8FCAE5C907E5}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Web", "Web\Web.csproj", "{EB3EE34B-8C85-4EC8-9E78-CFBECED2E0AD}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Web", "Web\Web.csproj", "{EB3EE34B-8C85-4EC8-9E78-CFBECED2E0AD}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{9359CCCA-F725-462F-AACD-8FCAE5C907E5} = {9359CCCA-F725-462F-AACD-8FCAE5C907E5}
|
||||
EndProjectSection
|
||||
|
@ -13,8 +13,8 @@ using Persistence;
|
||||
namespace Persistence.Migrations
|
||||
{
|
||||
[DbContext(typeof(RepositoryDbContext))]
|
||||
[Migration("20241210151814_mig2")]
|
||||
partial class mig2
|
||||
[Migration("20241210215030_mi")]
|
||||
partial class mi
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
@ -34,7 +34,8 @@ namespace Persistence.Migrations
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("character varying(100)");
|
||||
|
||||
b.Property<Guid>("RegionId")
|
||||
.HasColumnType("uuid");
|
||||
@ -57,7 +58,8 @@ namespace Persistence.Migrations
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("character varying(100)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
@ -82,7 +84,8 @@ namespace Persistence.Migrations
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("character varying(100)");
|
||||
|
||||
b.Property<int>("OkatoCode")
|
||||
.HasColumnType("integer");
|
@ -7,7 +7,7 @@ using Microsoft.EntityFrameworkCore.Migrations;
|
||||
namespace Persistence.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class mig2 : Migration
|
||||
public partial class mi : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
@ -17,7 +17,7 @@ namespace Persistence.Migrations
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
Name = table.Column<string>(type: "text", nullable: false),
|
||||
Name = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: false),
|
||||
Code = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
@ -30,7 +30,7 @@ namespace Persistence.Migrations
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
Name = table.Column<string>(type: "text", nullable: false),
|
||||
Name = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: false),
|
||||
RegionId = table.Column<Guid>(type: "uuid", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
@ -49,7 +49,7 @@ namespace Persistence.Migrations
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
Name = table.Column<string>(type: "text", nullable: false),
|
||||
Name = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: false),
|
||||
HouseNumbers = table.Column<List<int>>(type: "integer[]", nullable: false),
|
||||
Index = table.Column<int>(type: "integer", nullable: false),
|
||||
OkatoCode = table.Column<int>(type: "integer", nullable: false),
|
@ -31,7 +31,8 @@ namespace Persistence.Migrations
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("character varying(100)");
|
||||
|
||||
b.Property<Guid>("RegionId")
|
||||
.HasColumnType("uuid");
|
||||
@ -54,7 +55,8 @@ namespace Persistence.Migrations
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("character varying(100)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
@ -79,7 +81,8 @@ namespace Persistence.Migrations
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("character varying(100)");
|
||||
|
||||
b.Property<int>("OkatoCode")
|
||||
.HasColumnType("integer");
|
||||
|
@ -13,7 +13,9 @@
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="9.0.0" />
|
||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="9.0.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="9.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="9.0.0" />
|
||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="9.0.2" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -13,5 +13,9 @@ namespace Persistence
|
||||
: base(options)
|
||||
{
|
||||
}
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
modelBuilder.ApplyConfigurationsFromAssembly(typeof(RepositoryDbContext).Assembly);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
19
Address Directory/Persistence/RepositoryDbContextFactory.cs
Normal file
19
Address Directory/Persistence/RepositoryDbContextFactory.cs
Normal file
@ -0,0 +1,19 @@
|
||||
using Microsoft.EntityFrameworkCore.Design;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Persistence;
|
||||
|
||||
public class RepositoryDbContextFactory : IDesignTimeDbContextFactory<RepositoryDbContext>
|
||||
{
|
||||
public RepositoryDbContext CreateDbContext(string[] args)
|
||||
{
|
||||
var configuration = new ConfigurationBuilder()
|
||||
.SetBasePath(Path.Combine(Directory.GetCurrentDirectory(), "../Web"))
|
||||
.AddJsonFile("appsettings.json")
|
||||
.Build();
|
||||
var connectionString = configuration.GetConnectionString("Database");
|
||||
var optionsBuilder = new DbContextOptionsBuilder<RepositoryDbContext>();
|
||||
optionsBuilder.UseNpgsql(connectionString);
|
||||
return new RepositoryDbContext(optionsBuilder.Options);
|
||||
}
|
||||
}
|
@ -7,7 +7,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="2.2.5" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="2.1.38" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -9,16 +9,13 @@ using Services.Profiles;
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
var configuration = builder.Configuration;
|
||||
|
||||
var connectionString = builder.Configuration.GetConnectionString("Database");
|
||||
|
||||
builder.Services.AddControllers();
|
||||
|
||||
builder.Services.AddEndpointsApiExplorer();
|
||||
builder.Services.AddSwaggerGen();
|
||||
|
||||
builder.Services.AddDbContext<RepositoryDbContext>(
|
||||
options =>
|
||||
{
|
||||
options.UseNpgsql(configuration.GetConnectionString(nameof(RepositoryDbContext)));
|
||||
});
|
||||
|
||||
builder.Services.AddScoped<IRegionService, RegionService>();
|
||||
builder.Services.AddScoped<ICityService, CityService>();
|
||||
@ -28,8 +25,15 @@ builder.Services.AddScoped<IRegionRepository, RegionRepository>();
|
||||
builder.Services.AddScoped<ICityRepository, CityRepository>();
|
||||
builder.Services.AddScoped<IStreetRepository, StreetRepository>();
|
||||
|
||||
builder.Services.AddDbContext<RepositoryDbContext>(
|
||||
options =>
|
||||
{
|
||||
options.UseNpgsql(connectionString);
|
||||
});
|
||||
|
||||
builder.Services.AddAutoMapper(typeof(MappingProfile));
|
||||
var app = builder.Build();
|
||||
|
||||
if (app.Environment.IsDevelopment())
|
||||
{
|
||||
app.UseSwagger();
|
||||
|
@ -11,7 +11,8 @@
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="7.1.0" />
|
||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="9.0.2" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="7.2.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -5,8 +5,5 @@
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"ConnectionStrings": {
|
||||
"RepositoryDbContext":"Host=localhost;Port=5432;Database=AdressDb;Username=postgres;Password=postgres"
|
||||
}
|
||||
}
|
||||
|
@ -5,5 +5,8 @@
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*"
|
||||
"AllowedHosts": "*",
|
||||
"ConnectionStrings": {
|
||||
"Database": "Host=localhost;Port=5432;Database=AdressDb;Username=postgres;Password=postgres"
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user