Skip to content

Instantly share code, notes, and snippets.

@xximjasonxx

xximjasonxx/ctx.cs

Created Aug 2, 2020
Embed
What would you like to do?
public Class1
{
public Class1(DbContextOptions<MyContext> options) : base(options)
{
if (configuration["Env"] == "Cloud")
{
var conn = (Microsoft.Data.SqlClient.SqlConnection)Database.GetDbConnection();
conn.AccessToken = (new Microsoft.Azure.Services.AppAuthentication.AzureServiceTokenProvider()).GetAccessTokenAsync("https://database.windows.net/").Result;
}
Database.EnsureCreated();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.