Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
[TestClass]
public class CarServiceContextInitTests
{
// to have the same Configuration object as in Startup
private IConfigurationRoot _configuration;
// represents database's configuration
private DbContextOptions<CarServiceContext> _options;
public CarServiceContextInitTests()
{
var builder = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json");
_configuration = builder.Build();
_options = new DbContextOptionsBuilder<CarServiceContext>()
.UseSqlServer(_configuration.GetConnectionString("DefaultConnection"))
.Options;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment