Description
Describe what is not working as expected.
I expected that the startup registration would allow me to use the EF Tools without implementing a IDbConnectionFactory. I do not have an empty constructor on my context class, but by isn't the tooling using DI to create an instance? Here is my DbContext class:
public class VacationContext : DbContext
{
private IConfiguration _config;
public VacationContext(IConfiguration config, DbContextOptions builder): base(builder)
{
_config = config;
}
public DbSet<VacationRequest> VacationRequests { get; set; }
public DbSet<Employee> Employees { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
base.OnConfiguring(optionsBuilder);
optionsBuilder.UseSqlServer(_config["Data:MainConnection"]);
}
}
If you are seeing an exception, include the full exceptions details (message and stack trace).
d:\courses\PS\aspnetcore2\Examples\Exemplar\VacationPicker>dotnet ef database drop
Build succeeded.
0 Warning(s)
0 Error(s)
Time Elapsed 00:00:05.15
No parameterless constructor was found on 'VacationContext'. Either add a parameterless constructor to 'VacationContext' or add an implementation of 'IDbContextFactory<VacationContext>' in the same assembly as 'VacationContext'.
Steps to reproduce
Include a complete code listing (or project/solution) that we can run to reproduce the issue.
Partial code listings, or multiple fragments of code, will slow down our response or cause us to push the issue back to you to provide code to reproduce the issue.
<code listing>
Further technical details
EF Core version: (found in .csproj file)
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0-preview1-final" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.0.0-preview1-final" />
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.0-preview1-final" />
Database Provider: Microsoft.EntityFrameworkCore.SqlServer
Operating system: Win10
IDE: VS2017 Preview 1