Skip to content

Instantly share code, notes, and snippets.

@Lobstrosity
Created January 15, 2012 05:51
Show Gist options
  • Select an option

  • Save Lobstrosity/1614591 to your computer and use it in GitHub Desktop.

Select an option

Save Lobstrosity/1614591 to your computer and use it in GitHub Desktop.

Revisions

  1. Lobstrosity revised this gist Jan 15, 2012. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions OurContext.cs
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,7 @@
    public class OurContext : DbContext
    {
    public string ClientKey { get; private set; }

    /// We make use of the DbContext constructor overload that accepts a
    /// connection string to connect to.

  2. Lobstrosity created this gist Jan 15, 2012.
    19 changes: 19 additions & 0 deletions OurContext.cs
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    public class OurContext : DbContext
    {
    /// We make use of the DbContext constructor overload that accepts a
    /// connection string to connect to.

    public OurContext(string clientKey)
    : base(GetClientConnectionString(clientKey))
    {
    ClientKey = clientKey;
    }

    /// There's a static method in one of our base assemblies that returns a
    /// client's database connection string based on the client's short name.

    public static string GetClientConnectionString(string clientKey)
    {
    return AClassInOneOfOurBaseAssemblies.GetConnectionString(clientKey);
    }
    }