Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
L
lesson60
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Нурбек Созоев
lesson60
Commits
d3e8bf8d
Commit
d3e8bf8d
authored
Jun 03, 2019
by
Нурбек Созоев
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Добавил миграции для базы данных storedb
parent
c566e00b
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
212 additions
and
6 deletions
+212
-6
ProductController.cs
Store/Controllers/ProductController.cs
+0
-1
20190530151932_InitialMigration.Designer.cs
Store/Migrations/20190530151932_InitialMigration.Designer.cs
+43
-0
20190530151932_InitialMigration.cs
Store/Migrations/20190530151932_InitialMigration.cs
+31
-0
20190603135845_UpdateProductTable.Designer.cs
.../Migrations/20190603135845_UpdateProductTable.Designer.cs
+45
-0
20190603135845_UpdateProductTable.cs
Store/Migrations/20190603135845_UpdateProductTable.cs
+22
-0
ProductContextModelSnapshot.cs
Store/Migrations/ProductContextModelSnapshot.cs
+43
-0
Product.cs
Store/Models/Product.cs
+1
-0
ProductContext.cs
Store/Models/ProductContext.cs
+15
-0
Startup.cs
Store/Startup.cs
+4
-5
Store.csproj
Store/Store.csproj
+5
-0
appsettings.json
Store/appsettings.json
+3
-0
No files found.
Store/Controllers/ProductController.cs
View file @
d3e8bf8d
...
...
@@ -52,7 +52,6 @@ namespace Store.Controllers
return
View
();
}
[
HttpPost
]
public
IActionResult
Create
(
Product
product
)
{
...
...
Store/Migrations/20190530151932_InitialMigration.Designer.cs
0 → 100644
View file @
d3e8bf8d
// <auto-generated />
using
Microsoft.EntityFrameworkCore
;
using
Microsoft.EntityFrameworkCore.Infrastructure
;
using
Microsoft.EntityFrameworkCore.Migrations
;
using
Microsoft.EntityFrameworkCore.Storage.ValueConversion
;
using
Npgsql.EntityFrameworkCore.PostgreSQL.Metadata
;
using
Store.Models
;
namespace
Store.Migrations
{
[
DbContext
(
typeof
(
ProductContext
))]
[
Migration
(
"20190530151932_InitialMigration"
)]
partial
class
InitialMigration
{
protected
override
void
BuildTargetModel
(
ModelBuilder
modelBuilder
)
{
#pragma warning disable 612, 618
modelBuilder
.
HasAnnotation
(
"Npgsql:ValueGenerationStrategy"
,
NpgsqlValueGenerationStrategy
.
SerialColumn
)
.
HasAnnotation
(
"ProductVersion"
,
"2.2.4-servicing-10062"
)
.
HasAnnotation
(
"Relational:MaxIdentifierLength"
,
63
);
modelBuilder
.
Entity
(
"Store.Models.Product"
,
b
=>
{
b
.
Property
<
string
>(
"Id"
)
.
ValueGeneratedOnAdd
();
b
.
Property
<
int
>(
"Amount"
);
b
.
Property
<
string
>(
"Brand"
);
b
.
Property
<
string
>(
"Category"
);
b
.
Property
<
string
>(
"Name"
);
b
.
HasKey
(
"Id"
);
b
.
ToTable
(
"Products"
);
});
#pragma warning restore 612, 618
}
}
}
Store/Migrations/20190530151932_InitialMigration.cs
0 → 100644
View file @
d3e8bf8d
using
Microsoft.EntityFrameworkCore.Migrations
;
namespace
Store.Migrations
{
public
partial
class
InitialMigration
:
Migration
{
protected
override
void
Up
(
MigrationBuilder
migrationBuilder
)
{
migrationBuilder
.
CreateTable
(
name
:
"Products"
,
columns
:
table
=>
new
{
Id
=
table
.
Column
<
string
>(
nullable
:
false
),
Name
=
table
.
Column
<
string
>(
nullable
:
true
),
Category
=
table
.
Column
<
string
>(
nullable
:
true
),
Brand
=
table
.
Column
<
string
>(
nullable
:
true
),
Amount
=
table
.
Column
<
int
>(
nullable
:
false
)
},
constraints
:
table
=>
{
table
.
PrimaryKey
(
"PK_Products"
,
x
=>
x
.
Id
);
});
}
protected
override
void
Down
(
MigrationBuilder
migrationBuilder
)
{
migrationBuilder
.
DropTable
(
name
:
"Products"
);
}
}
}
Store/Migrations/20190603135845_UpdateProductTable.Designer.cs
0 → 100644
View file @
d3e8bf8d
// <auto-generated />
using
Microsoft.EntityFrameworkCore
;
using
Microsoft.EntityFrameworkCore.Infrastructure
;
using
Microsoft.EntityFrameworkCore.Migrations
;
using
Microsoft.EntityFrameworkCore.Storage.ValueConversion
;
using
Npgsql.EntityFrameworkCore.PostgreSQL.Metadata
;
using
Store.Models
;
namespace
Store.Migrations
{
[
DbContext
(
typeof
(
ProductContext
))]
[
Migration
(
"20190603135845_UpdateProductTable"
)]
partial
class
UpdateProductTable
{
protected
override
void
BuildTargetModel
(
ModelBuilder
modelBuilder
)
{
#pragma warning disable 612, 618
modelBuilder
.
HasAnnotation
(
"Npgsql:ValueGenerationStrategy"
,
NpgsqlValueGenerationStrategy
.
SerialColumn
)
.
HasAnnotation
(
"ProductVersion"
,
"2.2.4-servicing-10062"
)
.
HasAnnotation
(
"Relational:MaxIdentifierLength"
,
63
);
modelBuilder
.
Entity
(
"Store.Models.Product"
,
b
=>
{
b
.
Property
<
string
>(
"Id"
)
.
ValueGeneratedOnAdd
();
b
.
Property
<
int
>(
"Amount"
);
b
.
Property
<
string
>(
"Brand"
);
b
.
Property
<
string
>(
"Category"
);
b
.
Property
<
string
>(
"Description"
);
b
.
Property
<
string
>(
"Name"
);
b
.
HasKey
(
"Id"
);
b
.
ToTable
(
"Products"
);
});
#pragma warning restore 612, 618
}
}
}
Store/Migrations/20190603135845_UpdateProductTable.cs
0 → 100644
View file @
d3e8bf8d
using
Microsoft.EntityFrameworkCore.Migrations
;
namespace
Store.Migrations
{
public
partial
class
UpdateProductTable
:
Migration
{
protected
override
void
Up
(
MigrationBuilder
migrationBuilder
)
{
migrationBuilder
.
AddColumn
<
string
>(
name
:
"Description"
,
table
:
"Products"
,
nullable
:
true
);
}
protected
override
void
Down
(
MigrationBuilder
migrationBuilder
)
{
migrationBuilder
.
DropColumn
(
name
:
"Description"
,
table
:
"Products"
);
}
}
}
Store/Migrations/ProductContextModelSnapshot.cs
0 → 100644
View file @
d3e8bf8d
// <auto-generated />
using
Microsoft.EntityFrameworkCore
;
using
Microsoft.EntityFrameworkCore.Infrastructure
;
using
Microsoft.EntityFrameworkCore.Storage.ValueConversion
;
using
Npgsql.EntityFrameworkCore.PostgreSQL.Metadata
;
using
Store.Models
;
namespace
Store.Migrations
{
[
DbContext
(
typeof
(
ProductContext
))]
partial
class
ProductContextModelSnapshot
:
ModelSnapshot
{
protected
override
void
BuildModel
(
ModelBuilder
modelBuilder
)
{
#pragma warning disable 612, 618
modelBuilder
.
HasAnnotation
(
"Npgsql:ValueGenerationStrategy"
,
NpgsqlValueGenerationStrategy
.
SerialColumn
)
.
HasAnnotation
(
"ProductVersion"
,
"2.2.4-servicing-10062"
)
.
HasAnnotation
(
"Relational:MaxIdentifierLength"
,
63
);
modelBuilder
.
Entity
(
"Store.Models.Product"
,
b
=>
{
b
.
Property
<
string
>(
"Id"
)
.
ValueGeneratedOnAdd
();
b
.
Property
<
int
>(
"Amount"
);
b
.
Property
<
string
>(
"Brand"
);
b
.
Property
<
string
>(
"Category"
);
b
.
Property
<
string
>(
"Description"
);
b
.
Property
<
string
>(
"Name"
);
b
.
HasKey
(
"Id"
);
b
.
ToTable
(
"Products"
);
});
#pragma warning restore 612, 618
}
}
}
Store/Models/Product.cs
View file @
d3e8bf8d
...
...
@@ -7,5 +7,6 @@ namespace Store.Models
public
string
Category
{
get
;
set
;
}
public
string
Brand
{
get
;
set
;
}
public
int
Amount
{
get
;
set
;
}
public
string
Description
{
get
;
set
;
}
}
}
Store/Models/ProductContext.cs
0 → 100644
View file @
d3e8bf8d
using
Microsoft.EntityFrameworkCore
;
namespace
Store.Models
{
public
class
ProductContext
:
DbContext
{
public
DbSet
<
Product
>
Products
{
get
;
set
;
}
public
ProductContext
(
DbContextOptions
<
ProductContext
>
options
)
:
base
(
options
)
{
}
}
}
Store/Startup.cs
View file @
d3e8bf8d
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Threading.Tasks
;
using
Microsoft.AspNetCore.Builder
;
using
Microsoft.AspNetCore.Hosting
;
using
Microsoft.AspNetCore.Http
;
using
Microsoft.AspNetCore.HttpsPolicy
;
using
Microsoft.AspNetCore.Mvc
;
using
Microsoft.EntityFrameworkCore
;
using
Microsoft.Extensions.Configuration
;
using
Microsoft.Extensions.DependencyInjection
;
using
Store.Models
;
namespace
Store
{
...
...
@@ -31,6 +28,8 @@ namespace Store
options
.
MinimumSameSitePolicy
=
SameSiteMode
.
None
;
});
string
connection
=
Configuration
.
GetConnectionString
(
"StoreConnection"
);
services
.
AddDbContext
<
ProductContext
>(
options
=>
options
.
UseNpgsql
(
connection
));
services
.
AddMvc
().
SetCompatibilityVersion
(
CompatibilityVersion
.
Version_2_1
);
}
...
...
Store/Store.csproj
View file @
d3e8bf8d
...
...
@@ -6,11 +6,16 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="EntityFramework" Version="6.1.3" />
<PackageReference Include="Microsoft.AspNetCore" Version="2.1.2" />
<PackageReference Include="Microsoft.AspNetCore.CookiePolicy" Version="2.1.1" />
<PackageReference Include="Microsoft.AspNetCore.HttpsPolicy" Version="2.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.1.1" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.1.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.2.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="2.2.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.2.4" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="2.2.4" />
</ItemGroup>
<ItemGroup>
...
...
Store/appsettings.json
View file @
d3e8bf8d
{
"ConnectionStrings"
:
{
"StoreConnection"
:
"Host=localhost;Database=storedb;Username=postgres;Password=1qaz@WSX"
},
"Logging"
:
{
"LogLevel"
:
{
"Default"
:
"Warning"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment