Skip to content

Instantly share code, notes, and snippets.

@phsantiago32
phsantiago32 / MyDbContext.cs
Created August 2, 2019 17:12
C# snippet for connecting to an Azure DB instance via access token in a .NET Core app
using Microsoft.Azure.Services.AppAuthentication;
using System.Data.SqlClient;
namespace MyApp.Infrastructure.EntityFramework
{
public class MyDbContext : DbContext
{
public MyDbContext()
{
var conn = (SqlConnection)this.Database.GetDbConnection();