Skip to content

Commit

Permalink
Merged dev into master
Browse files Browse the repository at this point in the history
  • Loading branch information
JonPSmith committed Nov 10, 2021
2 parents 05b529f + 7c71981 commit da53208
Show file tree
Hide file tree
Showing 22 changed files with 1,131 additions and 110 deletions.
21 changes: 21 additions & 0 deletions DataLayer/BookApp/EfCode/BookContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,26 @@ protected override void
modelBuilder.ApplyConfiguration(new PriceOfferConfig());
}
}

/******************************************************************************
* NOTES ON MIGRATION:
*
* see https://docs.microsoft.com/en-us/aspnet/core/data/ef-rp/migrations?tabs=visual-studio
*
* The following NuGet libraries must be loaded
* 1. Add to DataLayer: "Microsoft.EntityFrameworkCore.Tools"
* 2. Add to DataLayer: "Microsoft.EntityFrameworkCore.SqlServer" (or another database provider)
*
* 2. Using Package Manager Console commands
* The steps are:
* a) Make sure the default project is Test
* b) Use the PMC command
* Add-Migration Initial -Project DataLayer -Context BookContext -OutputDir BookApp\Migrations
*
* If you want to start afresh then:
* a) Delete the current database
* b) Delete all the class in the Migration directory
* c) follow the steps to add a migration
******************************************************************************/
}

23 changes: 23 additions & 0 deletions DataLayer/BookApp/EfCode/PostgreSqlContextFactory.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright (c) 2021 Jon P Smith, GitHub: JonPSmith, web: http://www.thereformedprogrammer.net/
// Licensed under MIT license. See License.txt in the project root for license information.

using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design;

namespace DataLayer.BookApp.EfCode
{
public class PostgreSqlContextFactory : IDesignTimeDbContextFactory<BookContext>
{
private const string connectionString =
"host=localhost;Database=TestSupport-Migrate;Username=postgres;Password=LetMeIn";

public BookContext CreateDbContext(string[] args)
{
var optionsBuilder =
new DbContextOptionsBuilder<BookContext>();
optionsBuilder.UseNpgsql(connectionString);

return new BookContext(optionsBuilder.Options);
}
}
}
205 changes: 205 additions & 0 deletions DataLayer/BookApp/Migrations/20211109142634_Initial.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit da53208

Please sign in to comment.