New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add-Migration on any dotnetcore project #7905
Comments
What version of |
@bricelam thanks for the response. I figured it out and posted the answer here |
Seems like #7540 (comment) Suddenly got |
I'm getting this as well
not at all sure how to proceed |
I think I have worked something out.
What works though is adding a core 2.0 console app to the solution (not editing the code) and setting that as my startup project just before running the add-migration command. So it would seem that there's some code in the web app that gets run when the app-mrigations command is issued. I'm guessing its the Main method...here's mine public class Program
{
public static void Main(string[] args)
{
var host = BuildWebHost(args);
using (var scope = host.Services.CreateScope())
{
var services = scope.ServiceProvider;
try
{
var context = services.GetRequiredService<AdminDataContext>();
DbInitializer.Initialize(context);
}
catch (Exception ex)
{
var logger = services.GetRequiredService<ILogger<Program>>();
logger.LogError(ex, "An error occurred while seeding the database.");
}
}
host.Run();
}
public static IWebHost BuildWebHost(string[] args)
{
return WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.Build();
}
} I can only assume there's something path-y going on when constructing the host that isn't working from the package manager console. I hope this gives someone who knows better a hint as to what is going on with this. EDIT: It looks like something I'm doing when building my container in the Startup class's ConfigureServices method |
I had the same problem with .net core 1.1 . |
Add-Migration Initial with success. |
I get an error when I to run add-migration with entitcore on any dotnetcore based project but the equivalent command works when targeting the full dotnetframework
Add-Migration : Exception calling "AddFromFile" with "1" argument(s): "'basePath' cannot be an empty string ("") or start with the null character.
Parameter name: basePath"
At line:1 char:1
see a snapshot of my code. It's a dotnetcore console app. Thesame will work if created the project based on dotnetframewok 4.6.1
Steps to reproduce
Further technical details
Database Provider: (e.g. Microsoft.EntityFrameworkCore.SqlServer)
Operating system:
IDE: (e.g. Visual Studio 2017)
The text was updated successfully, but these errors were encountered: