опапопа а вот и миграция

This commit is contained in:
VictoriaPresnyakova 2023-05-04 20:42:59 +04:00
parent 064dac213c
commit ea1841f8bb
9 changed files with 493 additions and 5 deletions

View File

@ -10,6 +10,14 @@
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.5">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\TransportGuideDatabaseImplements\TransportGuideDatabaseImplements.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TransportGuideDatabaseImplements.Implements
{
internal class RouteStorage
{
}
}

View File

@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TransportGuideDatabaseImplements.Implements
{
public class StopStorage
{
}
}

View File

@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TransportGuideDatabaseImplements.Implements
{
internal class TransportTypeStorage
{
}
}

View File

@ -0,0 +1,163 @@
// <auto-generated />
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using TransportGuideDatabaseImplements;
#nullable disable
namespace TransportGuideDatabaseImplements.Migrations
{
[DbContext(typeof(TransportGuideDB))]
[Migration("20230504163433_InitialCreate")]
partial class InitialCreate
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.5")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("TransportGuideDatabaseImplements.Models.Route", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("IP")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<int>("TransportTypeId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("TransportTypeId");
b.ToTable("Routes");
});
modelBuilder.Entity("TransportGuideDatabaseImplements.Models.Stop", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Stops");
});
modelBuilder.Entity("TransportGuideDatabaseImplements.Models.StopRoute", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("Nomer")
.HasColumnType("integer");
b.Property<int>("RouteId")
.HasColumnType("integer");
b.Property<int>("StopId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("RouteId");
b.HasIndex("StopId");
b.ToTable("StopRoutes");
});
modelBuilder.Entity("TransportGuideDatabaseImplements.Models.TransportType", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<double>("Price")
.HasColumnType("double precision");
b.HasKey("Id");
b.ToTable("TransportTypes");
});
modelBuilder.Entity("TransportGuideDatabaseImplements.Models.Route", b =>
{
b.HasOne("TransportGuideDatabaseImplements.Models.TransportType", "TransportType")
.WithMany("Routes")
.HasForeignKey("TransportTypeId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("TransportType");
});
modelBuilder.Entity("TransportGuideDatabaseImplements.Models.StopRoute", b =>
{
b.HasOne("TransportGuideDatabaseImplements.Models.Route", "Route")
.WithMany("Stops")
.HasForeignKey("RouteId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("TransportGuideDatabaseImplements.Models.Stop", "Stop")
.WithMany("StopRoutes")
.HasForeignKey("StopId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Route");
b.Navigation("Stop");
});
modelBuilder.Entity("TransportGuideDatabaseImplements.Models.Route", b =>
{
b.Navigation("Stops");
});
modelBuilder.Entity("TransportGuideDatabaseImplements.Models.Stop", b =>
{
b.Navigation("StopRoutes");
});
modelBuilder.Entity("TransportGuideDatabaseImplements.Models.TransportType", b =>
{
b.Navigation("Routes");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,121 @@
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace TransportGuideDatabaseImplements.Migrations
{
/// <inheritdoc />
public partial class InitialCreate : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Stops",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Name = table.Column<string>(type: "text", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Stops", x => x.Id);
});
migrationBuilder.CreateTable(
name: "TransportTypes",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Name = table.Column<string>(type: "text", nullable: false),
Price = table.Column<double>(type: "double precision", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_TransportTypes", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Routes",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
TransportTypeId = table.Column<int>(type: "integer", nullable: false),
Name = table.Column<string>(type: "text", nullable: false),
IP = table.Column<string>(type: "text", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Routes", x => x.Id);
table.ForeignKey(
name: "FK_Routes_TransportTypes_TransportTypeId",
column: x => x.TransportTypeId,
principalTable: "TransportTypes",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "StopRoutes",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
StopId = table.Column<int>(type: "integer", nullable: false),
RouteId = table.Column<int>(type: "integer", nullable: false),
Nomer = table.Column<int>(type: "integer", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_StopRoutes", x => x.Id);
table.ForeignKey(
name: "FK_StopRoutes_Routes_RouteId",
column: x => x.RouteId,
principalTable: "Routes",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_StopRoutes_Stops_StopId",
column: x => x.StopId,
principalTable: "Stops",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_Routes_TransportTypeId",
table: "Routes",
column: "TransportTypeId");
migrationBuilder.CreateIndex(
name: "IX_StopRoutes_RouteId",
table: "StopRoutes",
column: "RouteId");
migrationBuilder.CreateIndex(
name: "IX_StopRoutes_StopId",
table: "StopRoutes",
column: "StopId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "StopRoutes");
migrationBuilder.DropTable(
name: "Routes");
migrationBuilder.DropTable(
name: "Stops");
migrationBuilder.DropTable(
name: "TransportTypes");
}
}
}

View File

@ -0,0 +1,160 @@
// <auto-generated />
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using TransportGuideDatabaseImplements;
#nullable disable
namespace TransportGuideDatabaseImplements.Migrations
{
[DbContext(typeof(TransportGuideDB))]
partial class TransportGuideDBModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.5")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("TransportGuideDatabaseImplements.Models.Route", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("IP")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<int>("TransportTypeId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("TransportTypeId");
b.ToTable("Routes");
});
modelBuilder.Entity("TransportGuideDatabaseImplements.Models.Stop", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Stops");
});
modelBuilder.Entity("TransportGuideDatabaseImplements.Models.StopRoute", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("Nomer")
.HasColumnType("integer");
b.Property<int>("RouteId")
.HasColumnType("integer");
b.Property<int>("StopId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("RouteId");
b.HasIndex("StopId");
b.ToTable("StopRoutes");
});
modelBuilder.Entity("TransportGuideDatabaseImplements.Models.TransportType", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<double>("Price")
.HasColumnType("double precision");
b.HasKey("Id");
b.ToTable("TransportTypes");
});
modelBuilder.Entity("TransportGuideDatabaseImplements.Models.Route", b =>
{
b.HasOne("TransportGuideDatabaseImplements.Models.TransportType", "TransportType")
.WithMany("Routes")
.HasForeignKey("TransportTypeId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("TransportType");
});
modelBuilder.Entity("TransportGuideDatabaseImplements.Models.StopRoute", b =>
{
b.HasOne("TransportGuideDatabaseImplements.Models.Route", "Route")
.WithMany("Stops")
.HasForeignKey("RouteId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("TransportGuideDatabaseImplements.Models.Stop", "Stop")
.WithMany("StopRoutes")
.HasForeignKey("StopId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Route");
b.Navigation("Stop");
});
modelBuilder.Entity("TransportGuideDatabaseImplements.Models.Route", b =>
{
b.Navigation("Stops");
});
modelBuilder.Entity("TransportGuideDatabaseImplements.Models.Stop", b =>
{
b.Navigation("StopRoutes");
});
modelBuilder.Entity("TransportGuideDatabaseImplements.Models.TransportType", b =>
{
b.Navigation("Routes");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -16,7 +16,7 @@ namespace TransportGuideDatabaseImplements
{
if (optionsBuilder.IsConfigured == false)
{
optionsBuilder.UseNpgsql("Host=192.168.56.101;Port=5432;Database=TransportSubd;Username=postgres;Password=postgres");
optionsBuilder.UseNpgsql("Host=192.168.56.101;Port=5432;Database=TransportSubd;Username=postgres;Password=1502");
}
base.OnConfiguring(optionsBuilder);
}

View File

@ -6,12 +6,12 @@
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<Folder Include="Implements\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.5">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="7.0.4" />
</ItemGroup>