Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
W
webinar63
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
Нурбек Созоев
webinar63
Commits
a948edca
Commit
a948edca
authored
Jun 19, 2019
by
Нурбек Созоев
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Добавил миграцию для создания базы данных
parent
c161a0c9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
189 additions
and
5 deletions
+189
-5
20190619144333_InitialMigration.Designer.cs
...es/Migrations/20190619144333_InitialMigration.Designer.cs
+57
-0
20190619144333_InitialMigration.cs
MyCities/Migrations/20190619144333_InitialMigration.cs
+50
-0
MyCitiesDbContextModelSnapshot.cs
MyCities/Migrations/MyCitiesDbContextModelSnapshot.cs
+55
-0
City.cs
MyCities/Models/City.cs
+1
-0
MyCitiesDbContext.cs
MyCities/Models/MyCitiesDbContext.cs
+15
-0
Person.cs
MyCities/Models/Person.cs
+1
-0
MyCities.csproj
MyCities/MyCities.csproj
+3
-0
Startup.cs
MyCities/Startup.cs
+4
-5
appsettings.json
MyCities/appsettings.json
+3
-0
No files found.
MyCities/Migrations/20190619144333_InitialMigration.Designer.cs
0 → 100644
View file @
a948edca
// <auto-generated />
using
Microsoft.EntityFrameworkCore
;
using
Microsoft.EntityFrameworkCore.Infrastructure
;
using
Microsoft.EntityFrameworkCore.Migrations
;
using
Microsoft.EntityFrameworkCore.Storage.ValueConversion
;
using
MyCities.Models
;
using
Npgsql.EntityFrameworkCore.PostgreSQL.Metadata
;
namespace
MyCities.Migrations
{
[
DbContext
(
typeof
(
MyCitiesDbContext
))]
[
Migration
(
"20190619144333_InitialMigration"
)]
partial
class
InitialMigration
{
protected
override
void
BuildTargetModel
(
ModelBuilder
modelBuilder
)
{
#pragma warning disable 612, 618
modelBuilder
.
HasAnnotation
(
"Npgsql:ValueGenerationStrategy"
,
NpgsqlValueGenerationStrategy
.
SerialColumn
)
.
HasAnnotation
(
"ProductVersion"
,
"2.1.1-rtm-30846"
)
.
HasAnnotation
(
"Relational:MaxIdentifierLength"
,
63
);
modelBuilder
.
Entity
(
"MyCities.Models.City"
,
b
=>
{
b
.
Property
<
int
>(
"Id"
)
.
ValueGeneratedOnAdd
();
b
.
Property
<
string
>(
"Country"
);
b
.
Property
<
string
>(
"Name"
);
b
.
Property
<
int
>(
"Population"
);
b
.
HasKey
(
"Id"
);
b
.
ToTable
(
"Cities"
);
});
modelBuilder
.
Entity
(
"MyCities.Models.Person"
,
b
=>
{
b
.
Property
<
int
>(
"Id"
)
.
ValueGeneratedOnAdd
();
b
.
Property
<
string
>(
"AvatarImagePath"
);
b
.
Property
<
string
>(
"FullName"
);
b
.
Property
<
string
>(
"NickName"
);
b
.
HasKey
(
"Id"
);
b
.
ToTable
(
"Persons"
);
});
#pragma warning restore 612, 618
}
}
}
MyCities/Migrations/20190619144333_InitialMigration.cs
0 → 100644
View file @
a948edca
using
Microsoft.EntityFrameworkCore.Migrations
;
using
Npgsql.EntityFrameworkCore.PostgreSQL.Metadata
;
namespace
MyCities.Migrations
{
public
partial
class
InitialMigration
:
Migration
{
protected
override
void
Up
(
MigrationBuilder
migrationBuilder
)
{
migrationBuilder
.
CreateTable
(
name
:
"Cities"
,
columns
:
table
=>
new
{
Id
=
table
.
Column
<
int
>(
nullable
:
false
)
.
Annotation
(
"Npgsql:ValueGenerationStrategy"
,
NpgsqlValueGenerationStrategy
.
SerialColumn
),
Name
=
table
.
Column
<
string
>(
nullable
:
true
),
Country
=
table
.
Column
<
string
>(
nullable
:
true
),
Population
=
table
.
Column
<
int
>(
nullable
:
false
)
},
constraints
:
table
=>
{
table
.
PrimaryKey
(
"PK_Cities"
,
x
=>
x
.
Id
);
});
migrationBuilder
.
CreateTable
(
name
:
"Persons"
,
columns
:
table
=>
new
{
Id
=
table
.
Column
<
int
>(
nullable
:
false
)
.
Annotation
(
"Npgsql:ValueGenerationStrategy"
,
NpgsqlValueGenerationStrategy
.
SerialColumn
),
FullName
=
table
.
Column
<
string
>(
nullable
:
true
),
NickName
=
table
.
Column
<
string
>(
nullable
:
true
),
AvatarImagePath
=
table
.
Column
<
string
>(
nullable
:
true
)
},
constraints
:
table
=>
{
table
.
PrimaryKey
(
"PK_Persons"
,
x
=>
x
.
Id
);
});
}
protected
override
void
Down
(
MigrationBuilder
migrationBuilder
)
{
migrationBuilder
.
DropTable
(
name
:
"Cities"
);
migrationBuilder
.
DropTable
(
name
:
"Persons"
);
}
}
}
MyCities/Migrations/MyCitiesDbContextModelSnapshot.cs
0 → 100644
View file @
a948edca
// <auto-generated />
using
Microsoft.EntityFrameworkCore
;
using
Microsoft.EntityFrameworkCore.Infrastructure
;
using
Microsoft.EntityFrameworkCore.Storage.ValueConversion
;
using
MyCities.Models
;
using
Npgsql.EntityFrameworkCore.PostgreSQL.Metadata
;
namespace
MyCities.Migrations
{
[
DbContext
(
typeof
(
MyCitiesDbContext
))]
partial
class
MyCitiesDbContextModelSnapshot
:
ModelSnapshot
{
protected
override
void
BuildModel
(
ModelBuilder
modelBuilder
)
{
#pragma warning disable 612, 618
modelBuilder
.
HasAnnotation
(
"Npgsql:ValueGenerationStrategy"
,
NpgsqlValueGenerationStrategy
.
SerialColumn
)
.
HasAnnotation
(
"ProductVersion"
,
"2.1.1-rtm-30846"
)
.
HasAnnotation
(
"Relational:MaxIdentifierLength"
,
63
);
modelBuilder
.
Entity
(
"MyCities.Models.City"
,
b
=>
{
b
.
Property
<
int
>(
"Id"
)
.
ValueGeneratedOnAdd
();
b
.
Property
<
string
>(
"Country"
);
b
.
Property
<
string
>(
"Name"
);
b
.
Property
<
int
>(
"Population"
);
b
.
HasKey
(
"Id"
);
b
.
ToTable
(
"Cities"
);
});
modelBuilder
.
Entity
(
"MyCities.Models.Person"
,
b
=>
{
b
.
Property
<
int
>(
"Id"
)
.
ValueGeneratedOnAdd
();
b
.
Property
<
string
>(
"AvatarImagePath"
);
b
.
Property
<
string
>(
"FullName"
);
b
.
Property
<
string
>(
"NickName"
);
b
.
HasKey
(
"Id"
);
b
.
ToTable
(
"Persons"
);
});
#pragma warning restore 612, 618
}
}
}
MyCities/Models/City.cs
View file @
a948edca
...
...
@@ -2,6 +2,7 @@ namespace MyCities.Models
{
public
class
City
{
public
int
Id
{
get
;
set
;
}
public
string
Name
{
get
;
set
;
}
public
string
Country
{
get
;
set
;
}
public
int
Population
{
get
;
set
;
}
...
...
MyCities/Models/MyCitiesDbContext.cs
0 → 100644
View file @
a948edca
using
Microsoft.EntityFrameworkCore
;
namespace
MyCities.Models
{
public
class
MyCitiesDbContext
:
DbContext
{
public
DbSet
<
City
>
Cities
{
get
;
set
;
}
public
DbSet
<
Person
>
Persons
{
get
;
set
;
}
public
MyCitiesDbContext
(
DbContextOptions
<
MyCitiesDbContext
>
options
)
:
base
(
options
)
{
}
}
}
MyCities/Models/Person.cs
View file @
a948edca
...
...
@@ -2,6 +2,7 @@ namespace MyCities.Models
{
public
class
Person
{
public
int
Id
{
get
;
set
;
}
public
string
FullName
{
get
;
set
;
}
public
string
NickName
{
get
;
set
;
}
public
string
AvatarImagePath
{
get
;
set
;
}
...
...
MyCities/MyCities.csproj
View file @
a948edca
...
...
@@ -6,6 +6,9 @@
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL">
<Version>2.1.1.1</Version>
</PackageReference>
</ItemGroup>
</Project>
MyCities/Startup.cs
View file @
a948edca
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
MyCities.Models
;
...
...
@@ -33,6 +29,9 @@ namespace MyCities
options
.
MinimumSameSitePolicy
=
SameSiteMode
.
None
;
});
string
connectionString
=
Configuration
.
GetConnectionString
(
"Default"
);
services
.
AddDbContext
<
MyCitiesDbContext
>(
options
=>
options
.
UseNpgsql
(
connectionString
));
services
.
AddSingleton
<
ICityRepository
,
InMemoryCityRepository
>();
services
.
AddSingleton
<
IPersonRepository
,
InMemoryPersonRepository
>();
services
.
AddMvc
().
SetCompatibilityVersion
(
CompatibilityVersion
.
Version_2_1
);
...
...
MyCities/appsettings.json
View file @
a948edca
{
"ConnectionStrings"
:
{
"Default"
:
"Host=localhost;Database=MyCities;Username=postgres;Password=qwerty"
},
"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