-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#25 Infrastructure - BankAccountRepository - EF (Added migrations)
- Loading branch information
1 parent
6f8df27
commit ef3d5f6
Showing
8 changed files
with
199 additions
and
7 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
60 changes: 60 additions & 0 deletions
60
...ptivem.Kata.Banking.Infrastructure/Migrations/20220618173926_InitialMigration.Designer.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
36 changes: 36 additions & 0 deletions
36
src/Optivem.Kata.Banking.Infrastructure/Migrations/20220618173926_InitialMigration.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,36 @@ | ||
using System; | ||
using Microsoft.EntityFrameworkCore.Migrations; | ||
|
||
#nullable disable | ||
|
||
namespace Optivem.Kata.Banking.Infrastructure.Migrations | ||
{ | ||
public partial class InitialMigration : Migration | ||
{ | ||
protected override void Up(MigrationBuilder migrationBuilder) | ||
{ | ||
migrationBuilder.CreateTable( | ||
name: "BankAccounts", | ||
columns: table => new | ||
{ | ||
Id = table.Column<long>(type: "bigint", nullable: false) | ||
.Annotation("SqlServer:Identity", "1, 1"), | ||
AccountNumber = table.Column<string>(type: "nvarchar(max)", nullable: false), | ||
FirstName = table.Column<string>(type: "nvarchar(max)", nullable: false), | ||
LastName = table.Column<string>(type: "nvarchar(max)", nullable: false), | ||
OpeningDate = table.Column<DateTime>(type: "datetime2", nullable: false), | ||
Balance = table.Column<int>(type: "int", nullable: false) | ||
}, | ||
constraints: table => | ||
{ | ||
table.PrimaryKey("PK_BankAccounts", x => x.Id); | ||
}); | ||
} | ||
|
||
protected override void Down(MigrationBuilder migrationBuilder) | ||
{ | ||
migrationBuilder.DropTable( | ||
name: "BankAccounts"); | ||
} | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
src/Optivem.Kata.Banking.Infrastructure/Migrations/DatabaseContextModelSnapshot.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,58 @@ | ||
// <auto-generated /> | ||
using System; | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.EntityFrameworkCore.Infrastructure; | ||
using Microsoft.EntityFrameworkCore.Metadata; | ||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; | ||
using Optivem.Kata.Banking.Infrastructure.Persistence; | ||
|
||
#nullable disable | ||
|
||
namespace Optivem.Kata.Banking.Infrastructure.Migrations | ||
{ | ||
[DbContext(typeof(DatabaseContext))] | ||
partial class DatabaseContextModelSnapshot : ModelSnapshot | ||
{ | ||
protected override void BuildModel(ModelBuilder modelBuilder) | ||
{ | ||
#pragma warning disable 612, 618 | ||
modelBuilder | ||
.HasAnnotation("ProductVersion", "6.0.6") | ||
.HasAnnotation("Relational:MaxIdentifierLength", 128); | ||
|
||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); | ||
|
||
modelBuilder.Entity("Optivem.Kata.Banking.Infrastructure.Persistence.BankAccountRecord", b => | ||
{ | ||
b.Property<long>("Id") | ||
.ValueGeneratedOnAdd() | ||
.HasColumnType("bigint"); | ||
|
||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("Id"), 1L, 1); | ||
|
||
b.Property<string>("AccountNumber") | ||
.IsRequired() | ||
.HasColumnType("nvarchar(max)"); | ||
|
||
b.Property<int>("Balance") | ||
.HasColumnType("int"); | ||
|
||
b.Property<string>("FirstName") | ||
.IsRequired() | ||
.HasColumnType("nvarchar(max)"); | ||
|
||
b.Property<string>("LastName") | ||
.IsRequired() | ||
.HasColumnType("nvarchar(max)"); | ||
|
||
b.Property<DateTime>("OpeningDate") | ||
.HasColumnType("datetime2"); | ||
|
||
b.HasKey("Id"); | ||
|
||
b.ToTable("BankAccounts"); | ||
}); | ||
#pragma warning restore 612, 618 | ||
} | ||
} | ||
} |
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
22 changes: 22 additions & 0 deletions
22
src/Optivem.Kata.Banking.Infrastructure/Persistence/DatabaseContextFactory.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,22 @@ | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.EntityFrameworkCore.Design; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Optivem.Kata.Banking.Infrastructure.Persistence | ||
{ | ||
public class DatabaseContextFactory : IDesignTimeDbContextFactory<DatabaseContext> | ||
{ | ||
public DatabaseContext CreateDbContext(string[] args) | ||
{ | ||
var connectionString = "Data Source=localhost;Initial Catalog=BankingKata;Integrated Security=True;MultipleActiveResultSets=True;"; | ||
var optionsBuilder = new DbContextOptionsBuilder<DatabaseContext>(); | ||
optionsBuilder.UseSqlServer(connectionString); | ||
|
||
return new DatabaseContext(optionsBuilder.Options); | ||
} | ||
} | ||
} |
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