Created
August 2, 2020 12:26
-
-
Save xximjasonxx/5dd3842fe17694a9b533212ffd63246d 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 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