diff --git a/src/EFCore.Design/Design/DbContextActivator.cs b/src/EFCore.Design/Design/DbContextActivator.cs
index e41a7f54439..51141033347 100644
--- a/src/EFCore.Design/Design/DbContextActivator.cs
+++ b/src/EFCore.Design/Design/DbContextActivator.cs
@@ -22,11 +22,13 @@ public static class DbContextActivator
/// The type to instantiate.
/// The application's startup assembly.
/// The design-time report handler.
+ /// Arguments passed to the constructor.
/// The newly created object.
public static DbContext CreateInstance(
[NotNull] Type contextType,
[CanBeNull] Assembly startupAssembly = null,
- [CanBeNull] IOperationReportHandler reportHandler = null)
+ [CanBeNull] IOperationReportHandler reportHandler = null,
+ [CanBeNull] string[] arguments = null)
{
Check.NotNull(contextType, nameof(contextType));
@@ -34,7 +36,7 @@ public static DbContext CreateInstance(
new OperationReporter(reportHandler),
contextType.Assembly,
startupAssembly ?? contextType.Assembly,
- args: Array.Empty()) // TODO: Issue #8332
+ args: arguments ?? Array.Empty())
.CreateContext(contextType.FullName);
}
}
diff --git a/src/EFCore.Design/Design/Internal/AppServiceProviderFactory.cs b/src/EFCore.Design/Design/Internal/AppServiceProviderFactory.cs
index 57b9b0621dc..360c325b403 100644
--- a/src/EFCore.Design/Design/Internal/AppServiceProviderFactory.cs
+++ b/src/EFCore.Design/Design/Internal/AppServiceProviderFactory.cs
@@ -44,7 +44,7 @@ public virtual IServiceProvider Create([NotNull] string[] args)
_reporter.WriteVerbose(DesignStrings.FindingServiceProvider);
return CreateFromHosting(args)
- ?? CreateEmptyServiceProvider();
+ ?? CreateArgsServiceProvider(args);
}
private IServiceProvider CreateFromHosting(string[] args)
@@ -97,11 +97,13 @@ private IServiceProvider CreateFromHosting(string[] args)
}
}
- private IServiceProvider CreateEmptyServiceProvider()
+ private IServiceProvider CreateArgsServiceProvider(string[] args)
{
_reporter.WriteVerbose(DesignStrings.NoServiceProvider);
- return new ServiceCollection().BuildServiceProvider();
+ return new ServiceCollection()
+ .AddScoped(typeof(string[]), sp => args)
+ .BuildServiceProvider();
}
}
}
diff --git a/src/EFCore.Design/Design/OperationExecutor.cs b/src/EFCore.Design/Design/OperationExecutor.cs
index 755223fda9f..d9d20ca468b 100644
--- a/src/EFCore.Design/Design/OperationExecutor.cs
+++ b/src/EFCore.Design/Design/OperationExecutor.cs
@@ -47,6 +47,8 @@ public class OperationExecutor : MarshalByRefObject
/// startupTargetName--The assembly name of the startup project.
/// projectDir--The target project's root directory.
/// rootNamespace--The target project's root namespace.
+ /// language--The programming language to be used to generate classes.
+ /// appArgs--Extra arguments passed into the operation.
///
/// The .
/// The executor arguments.
@@ -61,9 +63,7 @@ public OperationExecutor([NotNull] IOperationReportHandler reportHandler, [NotNu
_projectDir = (string)args["projectDir"];
_rootNamespace = (string)args["rootNamespace"];
_language = (string)args["language"];
-
- // TODO: Flow in from tools (issue #8332)
- _designArgs = Array.Empty();
+ _designArgs = (string[])args["appArgs"];
var toolsVersion = (string)args["toolsVersion"];
var runtimeVersion = ProductInfo.GetVersion();
diff --git a/src/ef/Commands/CommandBase.cs b/src/ef/Commands/CommandBase.cs
index 1bdde78a788..1c708c7352e 100644
--- a/src/ef/Commands/CommandBase.cs
+++ b/src/ef/Commands/CommandBase.cs
@@ -1,6 +1,7 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+using System.Collections.Generic;
using Microsoft.DotNet.Cli.CommandLine;
using Microsoft.EntityFrameworkCore.Tools.Properties;
@@ -8,6 +9,8 @@ namespace Microsoft.EntityFrameworkCore.Tools.Commands
{
internal abstract class CommandBase
{
+ protected string[] RemainingArguments { get; private set; }
+
public virtual void Configure(CommandLineApplication command)
{
var verbose = command.Option("-v|--verbose", Resources.VerboseDescription);
@@ -15,6 +18,7 @@ public virtual void Configure(CommandLineApplication command)
var prefixOutput = command.Option("--prefix-output", Resources.PrefixDescription);
command.HandleResponseFiles = true;
+ RemainingArguments = command.RemainingArguments.ToArray();
command.OnExecute(
() =>
diff --git a/src/ef/Commands/DatabaseDropCommand.cs b/src/ef/Commands/DatabaseDropCommand.cs
index b1b076260de..30f73f5ed7c 100644
--- a/src/ef/Commands/DatabaseDropCommand.cs
+++ b/src/ef/Commands/DatabaseDropCommand.cs
@@ -15,7 +15,7 @@ protected override int Execute()
void LogDropCommand(Func