Commit 54a44fca authored by TTrueBenji's avatar TTrueBenji

Откатиться на предыдущий коммит.

***
- откатился на предыдущий коммит.
- подключил postgresql.
- добавил таблицу пользователей.
***
parent b9baac3d
// <auto-generated />
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using PhoneStore.Models;
namespace PhoneStore.Migrations
{
[DbContext(typeof(MobileContext))]
[Migration("20220622133702_Init")]
partial class Init
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "5.0.17");
modelBuilder.Entity("PhoneStore.Models.Basket", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int>("PhoneId")
.HasColumnType("INTEGER");
b.HasKey("Id");
b.HasIndex("PhoneId");
b.ToTable("Baskets");
});
modelBuilder.Entity("PhoneStore.Models.Order", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Address")
.HasColumnType("TEXT");
b.Property<string>("ContactPhone")
.HasColumnType("TEXT");
b.Property<int>("PhoneId")
.HasColumnType("INTEGER");
b.Property<string>("UserName")
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("PhoneId");
b.ToTable("Orders");
});
modelBuilder.Entity("PhoneStore.Models.Phone", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Company")
.HasColumnType("TEXT");
b.Property<string>("Name")
.HasColumnType("TEXT");
b.Property<decimal>("Price")
.HasColumnType("TEXT");
b.HasKey("Id");
b.ToTable("Phones");
});
modelBuilder.Entity("PhoneStore.Models.Basket", b =>
{
b.HasOne("PhoneStore.Models.Phone", "Phone")
.WithMany()
.HasForeignKey("PhoneId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Phone");
});
modelBuilder.Entity("PhoneStore.Models.Order", b =>
{
b.HasOne("PhoneStore.Models.Phone", "Phone")
.WithMany()
.HasForeignKey("PhoneId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Phone");
});
#pragma warning restore 612, 618
}
}
}
using Microsoft.EntityFrameworkCore.Migrations;
namespace PhoneStore.Migrations
{
public partial class BrandEntity : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "Company",
table: "Phones");
migrationBuilder.AddColumn<int>(
name: "BrandId",
table: "Phones",
type: "INTEGER",
nullable: false,
defaultValue: 0);
migrationBuilder.CreateTable(
name: "Brands",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Name = table.Column<string>(type: "TEXT", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Brands", x => x.Id);
});
migrationBuilder.CreateIndex(
name: "IX_Phones_BrandId",
table: "Phones",
column: "BrandId");
migrationBuilder.AddForeignKey(
name: "FK_Phones_Brands_BrandId",
table: "Phones",
column: "BrandId",
principalTable: "Brands",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Phones_Brands_BrandId",
table: "Phones");
migrationBuilder.DropTable(
name: "Brands");
migrationBuilder.DropIndex(
name: "IX_Phones_BrandId",
table: "Phones");
migrationBuilder.DropColumn(
name: "BrandId",
table: "Phones");
migrationBuilder.AddColumn<string>(
name: "Company",
table: "Phones",
type: "TEXT",
nullable: true);
}
}
}
using Microsoft.EntityFrameworkCore.Migrations;
namespace PhoneStore.Migrations
{
public partial class AddImageField : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Phones_Brands_BrandId",
table: "Phones");
migrationBuilder.AlterColumn<int>(
name: "BrandId",
table: "Phones",
type: "INTEGER",
nullable: true,
oldClrType: typeof(int),
oldType: "INTEGER");
migrationBuilder.AddColumn<string>(
name: "Image",
table: "Phones",
type: "TEXT",
nullable: true);
migrationBuilder.AddForeignKey(
name: "FK_Phones_Brands_BrandId",
table: "Phones",
column: "BrandId",
principalTable: "Brands",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.Sql(@$"UPDATE ""Phones""
SET ""Image"" = 'images\phoneImages\default.jpg'
WHERE ""Image"" IS NULL;");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Phones_Brands_BrandId",
table: "Phones");
migrationBuilder.DropColumn(
name: "Image",
table: "Phones");
migrationBuilder.AlterColumn<int>(
name: "BrandId",
table: "Phones",
type: "INTEGER",
nullable: false,
defaultValue: 0,
oldClrType: typeof(int),
oldType: "INTEGER",
oldNullable: true);
migrationBuilder.AddForeignKey(
name: "FK_Phones_Brands_BrandId",
table: "Phones",
column: "BrandId",
principalTable: "Brands",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
}
}
...@@ -4,28 +4,32 @@ using Microsoft.EntityFrameworkCore; ...@@ -4,28 +4,32 @@ using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using PhoneStore.Models; using PhoneStore.Models;
namespace PhoneStore.Migrations namespace PhoneStore.Migrations
{ {
[DbContext(typeof(MobileContext))] [DbContext(typeof(MobileContext))]
[Migration("20220630161925_AddImageField")] [Migration("20220704164942_Init")]
partial class AddImageField partial class Init
{ {
protected override void BuildTargetModel(ModelBuilder modelBuilder) protected override void BuildTargetModel(ModelBuilder modelBuilder)
{ {
#pragma warning disable 612, 618 #pragma warning disable 612, 618
modelBuilder modelBuilder
.HasAnnotation("ProductVersion", "5.0.17"); .HasAnnotation("Relational:MaxIdentifierLength", 63)
.HasAnnotation("ProductVersion", "5.0.17")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
modelBuilder.Entity("PhoneStore.Models.Basket", b => modelBuilder.Entity("PhoneStore.Models.Basket", b =>
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("INTEGER"); .HasColumnType("integer")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<int>("PhoneId") b.Property<int>("PhoneId")
.HasColumnType("INTEGER"); .HasColumnType("integer");
b.HasKey("Id"); b.HasKey("Id");
...@@ -38,10 +42,11 @@ namespace PhoneStore.Migrations ...@@ -38,10 +42,11 @@ namespace PhoneStore.Migrations
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("INTEGER"); .HasColumnType("integer")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<string>("Name") b.Property<string>("Name")
.HasColumnType("TEXT"); .HasColumnType("text");
b.HasKey("Id"); b.HasKey("Id");
...@@ -52,19 +57,20 @@ namespace PhoneStore.Migrations ...@@ -52,19 +57,20 @@ namespace PhoneStore.Migrations
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("INTEGER"); .HasColumnType("integer")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<string>("Address") b.Property<string>("Address")
.HasColumnType("TEXT"); .HasColumnType("text");
b.Property<string>("ContactPhone") b.Property<string>("ContactPhone")
.HasColumnType("TEXT"); .HasColumnType("text");
b.Property<int>("PhoneId") b.Property<int>("PhoneId")
.HasColumnType("INTEGER"); .HasColumnType("integer");
b.Property<string>("UserName") b.Property<string>("UserName")
.HasColumnType("TEXT"); .HasColumnType("text");
b.HasKey("Id"); b.HasKey("Id");
...@@ -77,19 +83,20 @@ namespace PhoneStore.Migrations ...@@ -77,19 +83,20 @@ namespace PhoneStore.Migrations
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("INTEGER"); .HasColumnType("integer")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<int?>("BrandId") b.Property<int?>("BrandId")
.HasColumnType("INTEGER"); .HasColumnType("integer");
b.Property<string>("Image") b.Property<string>("Image")
.HasColumnType("TEXT"); .HasColumnType("text");
b.Property<string>("Name") b.Property<string>("Name")
.HasColumnType("TEXT"); .HasColumnType("text");
b.Property<decimal>("Price") b.Property<decimal>("Price")
.HasColumnType("TEXT"); .HasColumnType("numeric");
b.HasKey("Id"); b.HasKey("Id");
......
using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
namespace PhoneStore.Migrations namespace PhoneStore.Migrations
{ {
...@@ -6,28 +7,48 @@ namespace PhoneStore.Migrations ...@@ -6,28 +7,48 @@ namespace PhoneStore.Migrations
{ {
protected override void Up(MigrationBuilder migrationBuilder) protected override void Up(MigrationBuilder migrationBuilder)
{ {
migrationBuilder.CreateTable(
name: "Brands",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Name = table.Column<string>(type: "text", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Brands", x => x.Id);
});
migrationBuilder.CreateTable( migrationBuilder.CreateTable(
name: "Phones", name: "Phones",
columns: table => new columns: table => new
{ {
Id = table.Column<int>(type: "INTEGER", nullable: false) Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Sqlite:Autoincrement", true), .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Name = table.Column<string>(type: "TEXT", nullable: true), Name = table.Column<string>(type: "text", nullable: true),
Company = table.Column<string>(type: "TEXT", nullable: true), Price = table.Column<decimal>(type: "numeric", nullable: false),
Price = table.Column<decimal>(type: "TEXT", nullable: false) BrandId = table.Column<int>(type: "integer", nullable: true),
Image = table.Column<string>(type: "text", nullable: true)
}, },
constraints: table => constraints: table =>
{ {
table.PrimaryKey("PK_Phones", x => x.Id); table.PrimaryKey("PK_Phones", x => x.Id);
table.ForeignKey(
name: "FK_Phones_Brands_BrandId",
column: x => x.BrandId,
principalTable: "Brands",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
}); });
migrationBuilder.CreateTable( migrationBuilder.CreateTable(
name: "Baskets", name: "Baskets",
columns: table => new columns: table => new
{ {
Id = table.Column<int>(type: "INTEGER", nullable: false) Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Sqlite:Autoincrement", true), .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
PhoneId = table.Column<int>(type: "INTEGER", nullable: false) PhoneId = table.Column<int>(type: "integer", nullable: false)
}, },
constraints: table => constraints: table =>
{ {
...@@ -44,12 +65,12 @@ namespace PhoneStore.Migrations ...@@ -44,12 +65,12 @@ namespace PhoneStore.Migrations
name: "Orders", name: "Orders",
columns: table => new columns: table => new
{ {
Id = table.Column<int>(type: "INTEGER", nullable: false) Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Sqlite:Autoincrement", true), .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
UserName = table.Column<string>(type: "TEXT", nullable: true), UserName = table.Column<string>(type: "text", nullable: true),
ContactPhone = table.Column<string>(type: "TEXT", nullable: true), ContactPhone = table.Column<string>(type: "text", nullable: true),
Address = table.Column<string>(type: "TEXT", nullable: true), Address = table.Column<string>(type: "text", nullable: true),
PhoneId = table.Column<int>(type: "INTEGER", nullable: false) PhoneId = table.Column<int>(type: "integer", nullable: false)
}, },
constraints: table => constraints: table =>
{ {
...@@ -71,6 +92,11 @@ namespace PhoneStore.Migrations ...@@ -71,6 +92,11 @@ namespace PhoneStore.Migrations
name: "IX_Orders_PhoneId", name: "IX_Orders_PhoneId",
table: "Orders", table: "Orders",
column: "PhoneId"); column: "PhoneId");
migrationBuilder.CreateIndex(
name: "IX_Phones_BrandId",
table: "Phones",
column: "BrandId");
} }
protected override void Down(MigrationBuilder migrationBuilder) protected override void Down(MigrationBuilder migrationBuilder)
...@@ -83,6 +109,9 @@ namespace PhoneStore.Migrations ...@@ -83,6 +109,9 @@ namespace PhoneStore.Migrations
migrationBuilder.DropTable( migrationBuilder.DropTable(
name: "Phones"); name: "Phones");
migrationBuilder.DropTable(
name: "Brands");
} }
} }
} }
// <auto-generated /> // <auto-generated />
using System;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using PhoneStore.Models; using PhoneStore.Models;
namespace PhoneStore.Migrations namespace PhoneStore.Migrations
{ {
[DbContext(typeof(MobileContext))] [DbContext(typeof(MobileContext))]
[Migration("20220630102229_BrandEntity")] [Migration("20220704165134_UserEntity")]
partial class BrandEntity partial class UserEntity
{ {
protected override void BuildTargetModel(ModelBuilder modelBuilder) protected override void BuildTargetModel(ModelBuilder modelBuilder)
{ {
#pragma warning disable 612, 618 #pragma warning disable 612, 618
modelBuilder modelBuilder
.HasAnnotation("ProductVersion", "5.0.17"); .HasAnnotation("Relational:MaxIdentifierLength", 63)
.HasAnnotation("ProductVersion", "5.0.17")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
modelBuilder.Entity("PhoneStore.Models.Basket", b => modelBuilder.Entity("PhoneStore.Models.Basket", b =>
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("INTEGER"); .HasColumnType("integer")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<int>("PhoneId") b.Property<int>("PhoneId")
.HasColumnType("INTEGER"); .HasColumnType("integer");
b.HasKey("Id"); b.HasKey("Id");
...@@ -37,10 +42,11 @@ namespace PhoneStore.Migrations ...@@ -37,10 +42,11 @@ namespace PhoneStore.Migrations
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("INTEGER"); .HasColumnType("integer")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<string>("Name") b.Property<string>("Name")
.HasColumnType("TEXT"); .HasColumnType("text");
b.HasKey("Id"); b.HasKey("Id");
...@@ -51,19 +57,20 @@ namespace PhoneStore.Migrations ...@@ -51,19 +57,20 @@ namespace PhoneStore.Migrations
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("INTEGER"); .HasColumnType("integer")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<string>("Address") b.Property<string>("Address")
.HasColumnType("TEXT"); .HasColumnType("text");
b.Property<string>("ContactPhone") b.Property<string>("ContactPhone")
.HasColumnType("TEXT"); .HasColumnType("text");
b.Property<int>("PhoneId") b.Property<int>("PhoneId")
.HasColumnType("INTEGER"); .HasColumnType("integer");
b.Property<string>("UserName") b.Property<string>("UserName")
.HasColumnType("TEXT"); .HasColumnType("text");
b.HasKey("Id"); b.HasKey("Id");
...@@ -76,16 +83,20 @@ namespace PhoneStore.Migrations ...@@ -76,16 +83,20 @@ namespace PhoneStore.Migrations
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("INTEGER"); .HasColumnType("integer")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<int>("BrandId") b.Property<int?>("BrandId")
.HasColumnType("INTEGER"); .HasColumnType("integer");
b.Property<string>("Image")
.HasColumnType("text");
b.Property<string>("Name") b.Property<string>("Name")
.HasColumnType("TEXT"); .HasColumnType("text");
b.Property<decimal>("Price") b.Property<decimal>("Price")
.HasColumnType("TEXT"); .HasColumnType("numeric");
b.HasKey("Id"); b.HasKey("Id");
...@@ -94,6 +105,24 @@ namespace PhoneStore.Migrations ...@@ -94,6 +105,24 @@ namespace PhoneStore.Migrations
b.ToTable("Phones"); b.ToTable("Phones");
}); });
modelBuilder.Entity("PhoneStore.Models.User", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<int>("Age")
.HasColumnType("integer");
b.Property<string>("Name")
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Users");
});
modelBuilder.Entity("PhoneStore.Models.Basket", b => modelBuilder.Entity("PhoneStore.Models.Basket", b =>
{ {
b.HasOne("PhoneStore.Models.Phone", "Phone") b.HasOne("PhoneStore.Models.Phone", "Phone")
...@@ -120,9 +149,7 @@ namespace PhoneStore.Migrations ...@@ -120,9 +149,7 @@ namespace PhoneStore.Migrations
{ {
b.HasOne("PhoneStore.Models.Brand", "Brand") b.HasOne("PhoneStore.Models.Brand", "Brand")
.WithMany() .WithMany()
.HasForeignKey("BrandId") .HasForeignKey("BrandId");
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Brand"); b.Navigation("Brand");
}); });
......
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
namespace PhoneStore.Migrations
{
public partial class UserEntity : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Users",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Name = table.Column<string>(type: "text", nullable: true),
Age = table.Column<int>(type: "integer", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Users", x => x.Id);
});
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Users");
}
}
}
...@@ -3,6 +3,7 @@ using System; ...@@ -3,6 +3,7 @@ using System;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using PhoneStore.Models; using PhoneStore.Models;
namespace PhoneStore.Migrations namespace PhoneStore.Migrations
...@@ -14,16 +15,19 @@ namespace PhoneStore.Migrations ...@@ -14,16 +15,19 @@ namespace PhoneStore.Migrations
{ {
#pragma warning disable 612, 618 #pragma warning disable 612, 618
modelBuilder modelBuilder
.HasAnnotation("ProductVersion", "5.0.17"); .HasAnnotation("Relational:MaxIdentifierLength", 63)
.HasAnnotation("ProductVersion", "5.0.17")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
modelBuilder.Entity("PhoneStore.Models.Basket", b => modelBuilder.Entity("PhoneStore.Models.Basket", b =>
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("INTEGER"); .HasColumnType("integer")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<int>("PhoneId") b.Property<int>("PhoneId")
.HasColumnType("INTEGER"); .HasColumnType("integer");
b.HasKey("Id"); b.HasKey("Id");
...@@ -36,10 +40,11 @@ namespace PhoneStore.Migrations ...@@ -36,10 +40,11 @@ namespace PhoneStore.Migrations
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("INTEGER"); .HasColumnType("integer")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<string>("Name") b.Property<string>("Name")
.HasColumnType("TEXT"); .HasColumnType("text");
b.HasKey("Id"); b.HasKey("Id");
...@@ -50,19 +55,20 @@ namespace PhoneStore.Migrations ...@@ -50,19 +55,20 @@ namespace PhoneStore.Migrations
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("INTEGER"); .HasColumnType("integer")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<string>("Address") b.Property<string>("Address")
.HasColumnType("TEXT"); .HasColumnType("text");
b.Property<string>("ContactPhone") b.Property<string>("ContactPhone")
.HasColumnType("TEXT"); .HasColumnType("text");
b.Property<int>("PhoneId") b.Property<int>("PhoneId")
.HasColumnType("INTEGER"); .HasColumnType("integer");
b.Property<string>("UserName") b.Property<string>("UserName")
.HasColumnType("TEXT"); .HasColumnType("text");
b.HasKey("Id"); b.HasKey("Id");
...@@ -75,19 +81,20 @@ namespace PhoneStore.Migrations ...@@ -75,19 +81,20 @@ namespace PhoneStore.Migrations
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("INTEGER"); .HasColumnType("integer")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<int?>("BrandId") b.Property<int?>("BrandId")
.HasColumnType("INTEGER"); .HasColumnType("integer");
b.Property<string>("Image") b.Property<string>("Image")
.HasColumnType("TEXT"); .HasColumnType("text");
b.Property<string>("Name") b.Property<string>("Name")
.HasColumnType("TEXT"); .HasColumnType("text");
b.Property<decimal>("Price") b.Property<decimal>("Price")
.HasColumnType("TEXT"); .HasColumnType("numeric");
b.HasKey("Id"); b.HasKey("Id");
...@@ -96,6 +103,24 @@ namespace PhoneStore.Migrations ...@@ -96,6 +103,24 @@ namespace PhoneStore.Migrations
b.ToTable("Phones"); b.ToTable("Phones");
}); });
modelBuilder.Entity("PhoneStore.Models.User", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<int>("Age")
.HasColumnType("integer");
b.Property<string>("Name")
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Users");
});
modelBuilder.Entity("PhoneStore.Models.Basket", b => modelBuilder.Entity("PhoneStore.Models.Basket", b =>
{ {
b.HasOne("PhoneStore.Models.Phone", "Phone") b.HasOne("PhoneStore.Models.Phone", "Phone")
......
...@@ -8,6 +8,7 @@ namespace PhoneStore.Models ...@@ -8,6 +8,7 @@ namespace PhoneStore.Models
public DbSet<Order> Orders { get; set; } public DbSet<Order> Orders { get; set; }
public DbSet<Basket> Baskets { get; set; } public DbSet<Basket> Baskets { get; set; }
public DbSet<Brand> Brands { get; set; } public DbSet<Brand> Brands { get; set; }
public DbSet<User> Users { get; set; }
public MobileContext(DbContextOptions<MobileContext> options) : base(options) public MobileContext(DbContextOptions<MobileContext> options) : base(options)
{ {
......
namespace PhoneStore.Models
{
public class User
{
public int Id { get; set; }
public string Name { get; set; }
public int Age { get; set; }
}
}
\ No newline at end of file
...@@ -9,15 +9,11 @@ ...@@ -9,15 +9,11 @@
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="5.0.17" /> <PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="5.0.10" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<_ContentIncludedByDefault Remove="wwwroot\Files\book.pdf" /> <_ContentIncludedByDefault Remove="wwwroot\Files\book.pdf" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Folder Include="Migrations" />
</ItemGroup>
</Project> </Project>
...@@ -25,7 +25,7 @@ namespace PhoneStore ...@@ -25,7 +25,7 @@ namespace PhoneStore
public void ConfigureServices(IServiceCollection services) public void ConfigureServices(IServiceCollection services)
{ {
string connection = Configuration.GetConnectionString("DefaultConnection"); string connection = Configuration.GetConnectionString("DefaultConnection");
services.AddDbContext<MobileContext>(options => options.UseSqlite(connection)); services.AddDbContext<MobileContext>(options => options.UseNpgsql(connection));
services.AddControllersWithViews(); services.AddControllersWithViews();
services.AddScoped<IBasketService, BasketService>(); services.AddScoped<IBasketService, BasketService>();
services.AddTransient<UploadService>(); services.AddTransient<UploadService>();
......
{ {
"ConnectionStrings": { "ConnectionStrings": {
"DefaultConnection": "Data Source=Mobile.db;" "DefaultConnection": "Server=localhost;Port=54320;database=lesson55;Username=postgres;Password=postgres;"
}, },
"Logging": { "Logging": {
"LogLevel": { "LogLevel": {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment