Last active
November 10, 2017 01:30
-
-
Save dcomartin/493fb3d52357245f898f0da17cdfce7c to your computer and use it in GitHub Desktop.
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 class MyDbContext : DbContext | |
{ | |
public Guid TenantId { get; } | |
public string Connection { get; } | |
public DbSet<Customer> Customers { get; set; } | |
public MyDbContext(Guid tenantId, string connection) | |
{ | |
TenantId = tenantId; | |
Connection = connection; | |
this.Filter<Customer>(x => x.Where(q => q.TenantId == TenantId)); | |
} | |
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) | |
{ | |
optionsBuilder.UseSqlServer(Connection); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment