Skip to content

Commit da53208

Browse files
committed
Merged dev into master
2 parents 05b529f + 7c71981 commit da53208

22 files changed

+1131
-110
lines changed

DataLayer/BookApp/EfCode/BookContext.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,26 @@ protected override void
2424
modelBuilder.ApplyConfiguration(new PriceOfferConfig());
2525
}
2626
}
27+
28+
/******************************************************************************
29+
* NOTES ON MIGRATION:
30+
*
31+
* see https://docs.microsoft.com/en-us/aspnet/core/data/ef-rp/migrations?tabs=visual-studio
32+
*
33+
* The following NuGet libraries must be loaded
34+
* 1. Add to DataLayer: "Microsoft.EntityFrameworkCore.Tools"
35+
* 2. Add to DataLayer: "Microsoft.EntityFrameworkCore.SqlServer" (or another database provider)
36+
*
37+
* 2. Using Package Manager Console commands
38+
* The steps are:
39+
* a) Make sure the default project is Test
40+
* b) Use the PMC command
41+
* Add-Migration Initial -Project DataLayer -Context BookContext -OutputDir BookApp\Migrations
42+
*
43+
* If you want to start afresh then:
44+
* a) Delete the current database
45+
* b) Delete all the class in the Migration directory
46+
* c) follow the steps to add a migration
47+
******************************************************************************/
2748
}
2849

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Copyright (c) 2021 Jon P Smith, GitHub: JonPSmith, web: http://www.thereformedprogrammer.net/
2+
// Licensed under MIT license. See License.txt in the project root for license information.
3+
4+
using Microsoft.EntityFrameworkCore;
5+
using Microsoft.EntityFrameworkCore.Design;
6+
7+
namespace DataLayer.BookApp.EfCode
8+
{
9+
public class PostgreSqlContextFactory : IDesignTimeDbContextFactory<BookContext>
10+
{
11+
private const string connectionString =
12+
"host=localhost;Database=TestSupport-Migrate;Username=postgres;Password=LetMeIn";
13+
14+
public BookContext CreateDbContext(string[] args)
15+
{
16+
var optionsBuilder =
17+
new DbContextOptionsBuilder<BookContext>();
18+
optionsBuilder.UseNpgsql(connectionString);
19+
20+
return new BookContext(optionsBuilder.Options);
21+
}
22+
}
23+
}

DataLayer/BookApp/Migrations/20211109142634_Initial.Designer.cs

Lines changed: 205 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)