-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added DbContext and Migrations Management Script (#4)
Fix #3
- Loading branch information
Showing
13 changed files
with
466 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.6" /> | ||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.6"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.6" /> | ||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.6"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Domain\Domain.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Domain\Domain.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
96 changes: 96 additions & 0 deletions
96
Infrastructure/Migrations/20240703191648_initial-migration.Designer.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
76 changes: 76 additions & 0 deletions
76
Infrastructure/Migrations/20240703191648_initial-migration.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
using Microsoft.EntityFrameworkCore.Migrations; | ||
|
||
#nullable disable | ||
|
||
namespace Infrastructure.Migrations | ||
{ | ||
/// <inheritdoc /> | ||
public partial class initialmigration : Migration | ||
Check warning on line 8 in Infrastructure/Migrations/20240703191648_initial-migration.cs GitHub Actions / build
|
||
{ | ||
/// <inheritdoc /> | ||
protected override void Up(MigrationBuilder migrationBuilder) | ||
{ | ||
migrationBuilder.CreateTable( | ||
name: "Domains", | ||
columns: table => new | ||
{ | ||
Id = table.Column<int>(type: "int", nullable: false) | ||
.Annotation("SqlServer:Identity", "1, 1"), | ||
Domain = table.Column<string>(type: "nvarchar(max)", nullable: false), | ||
Active = table.Column<bool>(type: "bit", nullable: false) | ||
}, | ||
constraints: table => | ||
{ | ||
table.PrimaryKey("PK_Domains", x => x.Id); | ||
}); | ||
|
||
migrationBuilder.CreateTable( | ||
name: "Subdomains", | ||
columns: table => new | ||
{ | ||
Id = table.Column<int>(type: "int", nullable: false) | ||
.Annotation("SqlServer:Identity", "1, 1"), | ||
DomainId = table.Column<int>(type: "int", nullable: false), | ||
UserId = table.Column<int>(type: "int", nullable: false), | ||
SubdomainName = table.Column<string>(type: "nvarchar(max)", nullable: false) | ||
}, | ||
constraints: table => | ||
{ | ||
table.PrimaryKey("PK_Subdomains", x => x.Id); | ||
}); | ||
|
||
migrationBuilder.CreateTable( | ||
name: "Users", | ||
columns: table => new | ||
{ | ||
Id = table.Column<int>(type: "int", nullable: false) | ||
.Annotation("SqlServer:Identity", "1, 1"), | ||
Email = table.Column<string>(type: "nvarchar(450)", nullable: false), | ||
Username = table.Column<string>(type: "nvarchar(max)", nullable: false) | ||
}, | ||
constraints: table => | ||
{ | ||
table.PrimaryKey("PK_Users", x => x.Id); | ||
}); | ||
|
||
migrationBuilder.CreateIndex( | ||
name: "IX_Users_Email", | ||
table: "Users", | ||
column: "Email", | ||
unique: true); | ||
} | ||
|
||
/// <inheritdoc /> | ||
protected override void Down(MigrationBuilder migrationBuilder) | ||
{ | ||
migrationBuilder.DropTable( | ||
name: "Domains"); | ||
|
||
migrationBuilder.DropTable( | ||
name: "Subdomains"); | ||
|
||
migrationBuilder.DropTable( | ||
name: "Users"); | ||
} | ||
} | ||
} |
93 changes: 93 additions & 0 deletions
93
Infrastructure/Migrations/YourLabDbContextModelSnapshot.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
// <auto-generated /> | ||
using Infrastructure; | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.EntityFrameworkCore.Infrastructure; | ||
using Microsoft.EntityFrameworkCore.Metadata; | ||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; | ||
|
||
#nullable disable | ||
|
||
namespace Infrastructure.Migrations | ||
{ | ||
[DbContext(typeof(YourLabDbContext))] | ||
partial class YourLabDbContextModelSnapshot : ModelSnapshot | ||
{ | ||
protected override void BuildModel(ModelBuilder modelBuilder) | ||
{ | ||
#pragma warning disable 612, 618 | ||
modelBuilder | ||
.HasAnnotation("ProductVersion", "8.0.6") | ||
.HasAnnotation("Relational:MaxIdentifierLength", 128); | ||
|
||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); | ||
|
||
modelBuilder.Entity("Domain.Domains", b => | ||
{ | ||
b.Property<int>("Id") | ||
.ValueGeneratedOnAdd() | ||
.HasColumnType("int"); | ||
|
||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id")); | ||
|
||
b.Property<bool>("Active") | ||
.HasColumnType("bit"); | ||
|
||
b.Property<string>("Domain") | ||
.IsRequired() | ||
.HasColumnType("nvarchar(max)"); | ||
|
||
b.HasKey("Id"); | ||
|
||
b.ToTable("Domains"); | ||
}); | ||
|
||
modelBuilder.Entity("Domain.Subdomains", b => | ||
{ | ||
b.Property<int>("Id") | ||
.ValueGeneratedOnAdd() | ||
.HasColumnType("int"); | ||
|
||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id")); | ||
|
||
b.Property<int>("DomainId") | ||
.HasColumnType("int"); | ||
|
||
b.Property<string>("SubdomainName") | ||
.IsRequired() | ||
.HasColumnType("nvarchar(max)"); | ||
|
||
b.Property<int>("UserId") | ||
.HasColumnType("int"); | ||
|
||
b.HasKey("Id"); | ||
|
||
b.ToTable("Subdomains"); | ||
}); | ||
|
||
modelBuilder.Entity("Domain.User", b => | ||
{ | ||
b.Property<int>("Id") | ||
.ValueGeneratedOnAdd() | ||
.HasColumnType("int"); | ||
|
||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id")); | ||
|
||
b.Property<string>("Email") | ||
.IsRequired() | ||
.HasColumnType("nvarchar(450)"); | ||
|
||
b.Property<string>("Username") | ||
.IsRequired() | ||
.HasColumnType("nvarchar(max)"); | ||
|
||
b.HasKey("Id"); | ||
|
||
b.HasIndex("Email") | ||
.IsUnique(); | ||
|
||
b.ToTable("Users"); | ||
}); | ||
#pragma warning restore 612, 618 | ||
} | ||
} | ||
} |
Oops, something went wrong.