Last active
September 2, 2017 21:44
-
-
Save atrauzzi/5a00adb495c293260ec5 to your computer and use it in GitHub Desktop.
Using Postgres on Docker with EF7 and ASP.NET 5
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
namespace App { | |
using Microsoft.AspNet.Identity.EntityFramework; | |
using Microsoft.Data.Entity; | |
public class ApplicationDbContext : IdentityDbContext { | |
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { | |
// ToDo: Obtain these values from the environment, rather than hard-coding them. | |
optionsBuilder.UseNpgsql("Server=aspnet;Database=aspnet;Username=aspnet;Password=aspnet;"); | |
} | |
} | |
} |
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
database: | |
container_name: database | |
image: postgres | |
environment: | |
POSTGRES_USER: aspnet | |
POSTGRES_PASSWORD: aspnet | |
POSTGRES_DB: aspnet | |
ports: | |
- "5432:5432" |
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
"dependencies": { | |
"EntityFramework7.Npgsql": "3.1.0-rc1-3", | |
"EntityFramework.Commands": "7.0.0-rc1-final" | |
}, | |
"commands": { | |
"ef": "EntityFramework.Commands", | |
}, |
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
public void ConfigureServices(IServiceCollection services) { | |
services | |
.AddEntityFramework() | |
.AddNpgsql() | |
; | |
services | |
.AddIdentity<User, Role>() | |
.AddEntityFrameworkStores<ApplicationDbContext>() | |
; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment