Repository navigation
Closed as not planned
Closed as not planned
Copy link
Description
Error.
> dotnet ef migrations add initial
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ArgumentNullException: Value cannot be null.
Parameter name: assemblyName
at System.Reflection.AssemblyName..ctor(String assemblyName)
at Microsoft.AspNetCore.Mvc.Internal.DefaultAssemblyPartDiscoveryProvider.DiscoverAssemblyParts(String entryPointAssemblyName)
at Microsoft.Extensions.DependencyInjection.MvcCoreServiceCollectionExtensions.GetApplicationPartManager(IServiceCollection services)
at Microsoft.Extensions.DependencyInjection.MvcCoreServiceCollectionExtensions.AddMvcCore(IServiceCollection services)
at AlgaeApi.CloudComputer.Startup.ConfigureServices(IServiceCollection services) in C:\GitHub\2014-102MS-Monitoring\AlgaeApi\Startup.cs:line 29
--- End of inner exception stack trace ---
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at Microsoft.EntityFrameworkCore.Design.Internal.StartupInvoker.Invoke(Type type, String[] methodNames, IServiceCollection services)
at Microsoft.EntityFrameworkCore.Design.Internal.StartupInvoker.ConfigureServices()
at Microsoft.EntityFrameworkCore.Design.DbContextOperations..ctor(ILoggerProvider loggerProvider, Assembly assembly, Assembly startupAssembly, String environment, String startupProjectDir)
at Microsoft.EntityFrameworkCore.Design.MigrationsOperations..ctor(AssemblyLoader assemblyLoader, ILoggerProvider loggerProvider, Assembly assembly, Assembly startupAssembly, String environment, String projectDir, String startupProjectDir, String rootNamespace)
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.<>c__DisplayClass4_0.<.ctor>b__5()
at Microsoft.EntityFrameworkCore.Internal.LazyRef`1.get_Value()
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.AddMigrationImpl(String name, String outputDir, String contextType)
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.<>c__DisplayClass3_0`1.<Execute>b__0()
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action)
Exception has been thrown by the target of an invocation.
project.json
{
"compilationOptions": {
"emitEntryPoint": true,
"preserveCompilationContext": true
},
"dependencies": {
"Microsoft.EntityFrameworkCore.Sqlite": "1.0.0-*",
"Microsoft.EntityFrameworkCore.InMemory": "1.0.0-*",
"Microsoft.EntityFrameworkCore.Commands" : "1.0.0-*",
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.0-rc2-23931"
}
},
"tools": {
"dotnet-ef": {
"version": "1.0.0-*",
"imports": [
"dnxcore50",
"portable-net451+win8"
]
}
},
"frameworks": {
"netstandard1.5": {
"imports": [
"dnxcore50",
"portable-net451+win8"
]
}
}
}
Metadata
Metadata
Assignees
Labels
No labels
Activity
shaunluttin commentedon Apr 14, 2016
It turns out there are some things that the EF migrations do not like to see in the
Startupclass.services.AddMvcCore();services.AddCors();If either of those calls are inside
ConfigureServices, then the above migrations error occurs.natemcmaster commentedon Apr 14, 2016
This error is not being thrown from EF code. The change may need to be in MVC. I opened aspnet/Mvc#4479, but tracking here in case we need to change how EF discovers user services.
natemcmaster commentedon Apr 14, 2016
We found the issue. EF does not properly setup "HostingEnvironment" when discovering services, and MVC is not resilient to this. We need to replicate some of the logic in https://github.com/aspnet/Hosting/blob/dev/src/Microsoft.AspNetCore.Hosting/WebHostBuilder.cs#L180, adapted to EF's settings of course.
rowanmiller commentedon Apr 18, 2016
Closing as this is now tracked as part of #3925