Skip to content

Instantly share code, notes, and snippets.

@dudeNumber4
dudeNumber4 / ShardContext.cs
Created October 24, 2018 15:32
Entity Framework Context Constructor for Azure Shard
/// <summary>
/// Create EF context that will connect to Azure shard.
/// </summary>
/// <param name="operational">True if connecting for operational data (as opposed to historical). My solution only contains 2 shards so I can use bool. This could, for instance, simply be the integer parameter of the needed shard.</param>
public ShardContext(bool operational) : base(ShardManagement.GetRegularConnection(operational), true)
{
}
@dudeNumber4
dudeNumber4 / ShardManagement.cs
Last active October 24, 2018 15:31
Azure Shard Management
using Microsoft.Azure.SqlDatabase.ElasticScale.ShardManagement; // nuget package
using System;
using System.Configuration;
using System.Data.Common;
using System.Data.SqlClient;
using System.Diagnostics;
using System.Linq;
namespace ISharded.Data
{