From 07b37b878491810d75f36e5942656a1693f6f650 Mon Sep 17 00:00:00 2001 From: Brice Lambson Date: Wed, 9 Sep 2020 15:54:37 -0700 Subject: [PATCH 1/4] Tools: Review resource strings (#22469) Part of #7201 --- .../tools/EntityFrameworkCore.PS2.psm1 | 27 ++++++------ .../tools/EntityFrameworkCore.psm1 | 27 ++++++------ .../tools/about_EntityFrameworkCore.help.txt | 6 +-- .../Properties/Resources.Designer.cs | 42 +++++++++---------- src/dotnet-ef/Properties/Resources.resx | 36 ++++++++-------- .../DbContextScriptCommand.Configure.cs | 2 +- src/ef/Properties/Resources.Designer.cs | 28 ++++++++----- src/ef/Properties/Resources.resx | 25 ++++++----- 8 files changed, 102 insertions(+), 91 deletions(-) diff --git a/src/EFCore.Tools/tools/EntityFrameworkCore.PS2.psm1 b/src/EFCore.Tools/tools/EntityFrameworkCore.PS2.psm1 index d9037b9d088..98f6177938c 100644 --- a/src/EFCore.Tools/tools/EntityFrameworkCore.PS2.psm1 +++ b/src/EFCore.Tools/tools/EntityFrameworkCore.PS2.psm1 @@ -14,10 +14,10 @@ $versionErrorMessage = 'The Entity Framework Core Package Manager Console Tools The name of the migration. .PARAMETER OutputDir - The directory (and sub-namespace) to use. Paths are relative to the project directory. Defaults to "Migrations". + The directory to put files in. Paths are relative to the project directory. Defaults to "Migrations". .PARAMETER Context - The DbContext type to use. + The DbContext to use. .PARAMETER Project The project to use. @@ -26,7 +26,7 @@ $versionErrorMessage = 'The Entity Framework Core Package Manager Console Tools The startup project to use. Defaults to the solution's startup project. .PARAMETER Namespace - Specify to override the namespace for the migration. + The namespace to use. Defaults to match the directory. .PARAMETER Args Arguments passed to the application. @@ -89,10 +89,10 @@ function Enable-Migrations <# .SYNOPSIS - Gets information about DbContext types. + Lists and gets information about available DbContext types. .DESCRIPTION - Gets information about DbContext types. + Lists and gets information about available DbContext types. .PARAMETER Context The DbContext to use. @@ -129,6 +129,7 @@ function Get-DbContext( The connection string to the database. Defaults to the one specified in AddDbContext or OnConfiguring. .PARAMETER NoConnect + Don't connect to the database. .PARAMETER Context The DbContext to use. @@ -213,10 +214,10 @@ function Remove-Migration( The directory to put files in. Paths are relative to the project directory. .PARAMETER ContextDir - The directory to put DbContext file in. Paths are relative to the project directory. + The directory to put the DbContext file in. Paths are relative to the project directory. .PARAMETER Context - The name of the DbContext to generate. + The name of the DbContext. Defaults to the database name. .PARAMETER Schemas The schemas of tables to generate entity types for. @@ -234,7 +235,7 @@ function Remove-Migration( Overwrite existing files. .PARAMETER NoOnConfiguring - Suppress generation of the DbContext.OnConfiguring() method. + Don't generate DbContext.OnConfiguring. .PARAMETER Project The project to use. @@ -243,10 +244,10 @@ function Remove-Migration( The startup project to use. Defaults to the solution's startup project. .PARAMETER Namespace - Specify to override the namespace for the generated entity types. + The namespace to use. Defaults to match the directory. .PARAMETER ContextNamespace - Specify to override the namespace for the DbContext class. + The namespace of the DbContext class. Defaults to match the directory. .PARAMETER NoPluralize Don't use the pluralizer. @@ -281,10 +282,10 @@ function Scaffold-DbContext( <# .SYNOPSIS - Generates a SQL script from current DbContext. + Generates a SQL script from the DbContext. Bypasses any migrations. .DESCRIPTION - Generates a SQL script from current DbContext. + Generates a SQL script from the DbContext. Bypasses any migrations. .PARAMETER Output The file to write the result to. @@ -325,7 +326,7 @@ function Script-DbContext( The starting migration. Defaults to '0' (the initial database). .PARAMETER To - The ending migration. Defaults to the last migration. + The target migration. Defaults to the last migration. .PARAMETER Idempotent Generate a script that can be used on a database at any migration. diff --git a/src/EFCore.Tools/tools/EntityFrameworkCore.psm1 b/src/EFCore.Tools/tools/EntityFrameworkCore.psm1 index db2c92fda6e..f7b91cb2c71 100644 --- a/src/EFCore.Tools/tools/EntityFrameworkCore.psm1 +++ b/src/EFCore.Tools/tools/EntityFrameworkCore.psm1 @@ -22,10 +22,10 @@ Register-TabExpansion Add-Migration @{ The name of the migration. .PARAMETER OutputDir - The directory (and sub-namespace) to use. Paths are relative to the project directory. Defaults to "Migrations". + The directory to put files in. Paths are relative to the project directory. Defaults to "Migrations". .PARAMETER Context - The DbContext type to use. + The DbContext to use. .PARAMETER Project The project to use. @@ -34,7 +34,7 @@ Register-TabExpansion Add-Migration @{ The startup project to use. Defaults to the solution's startup project. .PARAMETER Namespace - Specify to override the namespace for the migration. + The namespace to use. Defaults to match the directory. .PARAMETER Args Arguments passed to the application. @@ -167,10 +167,10 @@ Register-TabExpansion Get-DbContext @{ <# .SYNOPSIS - Gets information about DbContext types. + Lists and gets information about available DbContext types. .DESCRIPTION - Gets information about DbContext types. + Lists and gets information about available DbContext types. .PARAMETER Context The DbContext to use. @@ -237,6 +237,7 @@ Register-TabExpansion Get-Migration @{ The connection string to the database. Defaults to the one specified in AddDbContext or OnConfiguring. .PARAMETER NoConnect + Don't connect to the database. .PARAMETER Context The DbContext to use. @@ -393,10 +394,10 @@ Register-TabExpansion Scaffold-DbContext @{ The directory to put files in. Paths are relative to the project directory. .PARAMETER ContextDir - The directory to put DbContext file in. Paths are relative to the project directory. + The directory to put the DbContext file in. Paths are relative to the project directory. .PARAMETER Context - The name of the DbContext to generate. + The name of the DbContext. Defaults to the database name. .PARAMETER Schemas The schemas of tables to generate entity types for. @@ -414,7 +415,7 @@ Register-TabExpansion Scaffold-DbContext @{ Overwrite existing files. .PARAMETER NoOnConfiguring - Suppress generation of the DbContext.OnConfiguring() method. + Don't generate DbContext.OnConfiguring. .PARAMETER Project The project to use. @@ -423,10 +424,10 @@ Register-TabExpansion Scaffold-DbContext @{ The startup project to use. Defaults to the solution's startup project. .PARAMETER Namespace - Specify to override the namespace for the generated entity types. + The namespace to use. Defaults to match the directory. .PARAMETER ContextNamespace - Specify to override the namespace for the DbContext class. + The namespace of the DbContext class. Defaults to match the directory. .PARAMETER NoPluralize Don't use the pluralizer. @@ -540,10 +541,10 @@ Register-TabExpansion Script-DbContext @{ <# .SYNOPSIS - Generates a SQL script from current DbContext. + Generates a SQL script from the DbContext. Bypasses any migrations. .DESCRIPTION - Generates a SQL script from current DbContext. + Generates a SQL script from the DbContext. Bypasses any migrations. .PARAMETER Output The file to write the result to. @@ -625,7 +626,7 @@ Register-TabExpansion Script-Migration @{ The starting migration. Defaults to '0' (the initial database). .PARAMETER To - The ending migration. Defaults to the last migration. + The target migration. Defaults to the last migration. .PARAMETER Idempotent Generate a script that can be used on a database at any migration. diff --git a/src/EFCore.Tools/tools/about_EntityFrameworkCore.help.txt b/src/EFCore.Tools/tools/about_EntityFrameworkCore.help.txt index bd8bfd36d62..faf0503e3ea 100644 --- a/src/EFCore.Tools/tools/about_EntityFrameworkCore.help.txt +++ b/src/EFCore.Tools/tools/about_EntityFrameworkCore.help.txt @@ -24,15 +24,15 @@ LONG DESCRIPTION Drop-Database Drops the database. - Get-DbContext Gets information about a DbContext type. + Get-DbContext Lists and gets information about available DbContext types. - Get-Migration Lists the migrations in the migration assembly. + Get-Migration Lists available migrations. Remove-Migration Removes the last migration. Scaffold-DbContext Scaffolds a DbContext and entity types for a database. - Script-DbContext Generates a SQL script from the current DbContext. + Script-DbContext Generates a SQL script from the DbContext. Bypasses any migrations. Script-Migration Generates a SQL script from migrations. diff --git a/src/dotnet-ef/Properties/Resources.Designer.cs b/src/dotnet-ef/Properties/Resources.Designer.cs index 4e46605f24c..b338165d490 100644 --- a/src/dotnet-ef/Properties/Resources.Designer.cs +++ b/src/dotnet-ef/Properties/Resources.Designer.cs @@ -19,7 +19,7 @@ private static readonly ResourceManager _resourceManager = new ResourceManager("Microsoft.EntityFrameworkCore.Tools.Properties.Resources", typeof(Resources).Assembly); /// - /// Build failed. + /// Build failed. Use dotnet build to see the errors. /// public static string BuildFailed => GetString("BuildFailed"); @@ -55,19 +55,19 @@ public static string ContextDescription => GetString("ContextDescription"); /// - /// The directory to put DbContext file in. Paths are relative to the project directory. + /// The directory to put the DbContext file in. Paths are relative to the project directory. /// public static string ContextDirDescription => GetString("ContextDirDescription"); /// - /// The name of the DbContext. + /// The name of the DbContext. Defaults to the database name. /// public static string ContextNameDescription => GetString("ContextNameDescription"); /// - /// Specify to override the namespace for the DbContext class. + /// The namespace of the DbContext class. Defaults to match the directory. /// public static string ContextNamespaceDescription => GetString("ContextNamespaceDescription"); @@ -144,6 +144,12 @@ public static string DbContextScaffoldDescription public static string DbContextScaffoldForceDescription => GetString("DbContextScaffoldForceDescription"); + /// + /// Generates a SQL script from the DbContext. Bypasses any migrations. + /// + public static string DbContextScriptDescription + => GetString("DbContextScriptDescription"); + /// /// Entity Framework Core .NET Command-line Tools /// @@ -157,13 +163,13 @@ public static string EFFullName => GetString("EFFullName"); /// - /// The target framework. + /// The target framework. Defaults to the first one in the project. /// public static string FrameworkDescription => GetString("FrameworkDescription"); /// - /// Unable to retrieve project metadata. Ensure it's an MSBuild-based .NET Core project. If you're using custom BaseIntermediateOutputPath or MSBuildProjectExtensionsPath values, Use the --msbuildprojectextensionspath option. + /// Unable to retrieve project metadata. Ensure it's an SDK-style project. If you're using a custom BaseIntermediateOutputPath or MSBuildProjectExtensionsPath values, Use the --msbuildprojectextensionspath option. /// public static string GetMetadataFailed => GetString("GetMetadataFailed"); @@ -183,7 +189,7 @@ public static string InvalidTemplatePattern([CanBeNull] object template) template); /// - /// Show JSON output. + /// Show JSON output. Use with --prefix-output to parse programatically. /// public static string JsonDescription => GetString("JsonDescription"); @@ -233,13 +239,13 @@ public static string MigrationsListDescription => GetString("MigrationsListDescription"); /// - /// Specify to override the namespace for the migration. + /// The namespace to use. Defaults to match the directory. /// public static string MigrationsNamespaceDescription => GetString("MigrationsNamespaceDescription"); /// - /// The directory (and sub-namespace) to use. Paths are relative to the project directory. Defaults to "Migrations". + /// The directory to put files in. Paths are relative to the project directory. Defaults to "Migrations". /// public static string MigrationsOutputDirDescription => GetString("MigrationsOutputDirDescription"); @@ -263,7 +269,7 @@ public static string MigrationsScriptDescription => GetString("MigrationsScriptDescription"); /// - /// The ending migration. Defaults to the last migration. + /// The target migration. Defaults to the last migration. /// public static string MigrationToDescription => GetString("MigrationToDescription"); @@ -289,7 +295,7 @@ public static string MultipleStartupProjects => GetString("MultipleStartupProjects"); /// - /// Specify to override the namespace for the generated entity types. + /// The namespace to use. Defaults to match the directory. /// public static string NamespaceDescription => GetString("NamespaceDescription"); @@ -311,7 +317,7 @@ public static string NETStandardStartupProject([CanBeNull] object startupProject startupProject); /// - /// Don't build the project. Only use this when the build is up-to-date. + /// Don't build the project. Only use when the build is up-to-date. /// public static string NoBuildDescription => GetString("NoBuildDescription"); @@ -373,7 +379,7 @@ public static string PrefixDescription => GetString("PrefixDescription"); /// - /// The project to use. + /// The project to use. Defaults to the current working directory. /// public static string ProjectDescription => GetString("ProjectDescription"); @@ -411,13 +417,13 @@ public static string SchemasDescription => GetString("SchemasDescription"); /// - /// The startup project to use. + /// The startup project to use. Defaults to the current working directory. /// public static string StartupProjectDescription => GetString("StartupProjectDescription"); /// - /// Suppress generation of the DbContext.OnConfiguring() method. + /// Don't generate DbContext.OnConfiguring. /// public static string SuppressOnConfiguringDescription => GetString("SuppressOnConfiguringDescription"); @@ -480,12 +486,6 @@ public static string UsingStartupProject([CanBeNull] object startupProject) public static string VerboseDescription => GetString("VerboseDescription"); - /// - /// The working directory of the tool invoking this command. - /// - public static string WorkingDirDescription - => GetString("WorkingDirDescription"); - /// /// Writing '{file}'... /// diff --git a/src/dotnet-ef/Properties/Resources.resx b/src/dotnet-ef/Properties/Resources.resx index 98b4bfd1bda..cfc60c7be89 100644 --- a/src/dotnet-ef/Properties/Resources.resx +++ b/src/dotnet-ef/Properties/Resources.resx @@ -118,7 +118,7 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - Build failed. + Build failed. Use dotnet build to see the errors. Build started... @@ -136,13 +136,13 @@ The DbContext to use. - The directory to put DbContext file in. Paths are relative to the project directory. + The directory to put the DbContext file in. Paths are relative to the project directory. - The name of the DbContext. + The name of the DbContext. Defaults to the database name. - Specify to override the namespace for the DbContext class. + The namespace of the DbContext class. Defaults to match the directory. Use attributes to configure the model (where possible). If omitted, only the fluent API is used. @@ -180,6 +180,9 @@ Overwrite existing files. + + Generates a SQL script from the DbContext. Bypasses any migrations. + Entity Framework Core .NET Command-line Tools @@ -187,10 +190,10 @@ Entity Framework Core Command-line Tools - The target framework. + The target framework. Defaults to the first one in the project. - Unable to retrieve project metadata. Ensure it's an MSBuild-based .NET Core project. If you're using custom BaseIntermediateOutputPath or MSBuildProjectExtensionsPath values, Use the --msbuildprojectextensionspath option. + Unable to retrieve project metadata. Ensure it's an SDK-style project. If you're using a custom BaseIntermediateOutputPath or MSBuildProjectExtensionsPath values, Use the --msbuildprojectextensionspath option. Generate a script that can be used on a database at any migration. @@ -199,7 +202,7 @@ Invalid template pattern '{template}'. - Show JSON output. + Show JSON output. Use with --prefix-output to parse programatically. The last argument '{argumentName}' accepts multiple values. No more argument can be added. @@ -223,10 +226,10 @@ Lists available migrations. - Specify to override the namespace for the migration. + The namespace to use. Defaults to match the directory. - The directory (and sub-namespace) to use. Paths are relative to the project directory. Defaults to "Migrations". + The directory to put files in. Paths are relative to the project directory. Defaults to "Migrations". Removes the last migration. @@ -238,7 +241,7 @@ Generates a SQL script from migrations. - The ending migration. Defaults to the last migration. + The target migration. Defaults to the last migration. More than one project was found in the current working directory. Use the --project option. @@ -250,7 +253,7 @@ More than one project was found in the current working directory. Use the --startup-project option. - Specify to override the namespace for the generated entity types. + The namespace to use. Defaults to match the directory. Startup project '{startupProject}' targets framework '.NETCoreApp' version '{targetFrameworkVersion}'. This version of the Entity Framework Core .NET Command-line Tools only supports version 2.0 or higher. For information on using older versions of the tools, see https://go.microsoft.com/fwlink/?linkid=871254 @@ -259,7 +262,7 @@ Startup project '{startupProject}' targets framework '.NETStandard'. There is no runtime associated with this framework, and projects targeting it cannot be executed directly. To use the Entity Framework Core .NET Command-line Tools with this project, add an executable project targeting .NET Core or .NET Framework that references this project, and set it as the startup project using --startup-project; or, update this project to cross-target .NET Core or .NET Framework. For more information on using the Entity Framework Tools with .NET Standard projects, see https://go.microsoft.com/fwlink/?linkid=2034781 - Don't build the project. Only use this when the build is up-to-date. + Don't build the project. Only use when the build is up-to-date. Don't colorize output. @@ -289,7 +292,7 @@ Prefix output with level. - The project to use. + The project to use. Defaults to the current working directory. The MSBuild project extensions path. Defaults to "obj". @@ -307,10 +310,10 @@ The schemas of tables to generate entity types for. - The startup project to use. + The startup project to use. Defaults to the current working directory. - Suppress generation of the DbContext.OnConfiguring() method. + Don't generate DbContext.OnConfiguring. The tables to generate entity types for. @@ -336,9 +339,6 @@ Show verbose output. - - The working directory of the tool invoking this command. - Writing '{file}'... diff --git a/src/ef/Commands/DbContextScriptCommand.Configure.cs b/src/ef/Commands/DbContextScriptCommand.Configure.cs index 863dfe24e02..b72239ea77d 100644 --- a/src/ef/Commands/DbContextScriptCommand.Configure.cs +++ b/src/ef/Commands/DbContextScriptCommand.Configure.cs @@ -12,7 +12,7 @@ internal partial class DbContextScriptCommand : ContextCommandBase public override void Configure(CommandLineApplication command) { - command.Description = Resources.MigrationsScriptDescription; + command.Description = Resources.DbContextScriptDescription; _output = command.Option("-o|--output ", Resources.OutputDescription); diff --git a/src/ef/Properties/Resources.Designer.cs b/src/ef/Properties/Resources.Designer.cs index 06ee3ea69cf..6fbd681cdf9 100644 --- a/src/ef/Properties/Resources.Designer.cs +++ b/src/ef/Properties/Resources.Designer.cs @@ -19,7 +19,7 @@ private static readonly ResourceManager _resourceManager = new ResourceManager("Microsoft.EntityFrameworkCore.Tools.Properties.Resources", typeof(Resources).Assembly); /// - /// The assembly to use. + /// The assembly to use. Required. /// public static string AssemblyDescription => GetString("AssemblyDescription"); @@ -37,19 +37,19 @@ public static string ContextDescription => GetString("ContextDescription"); /// - /// The directory to put DbContext file in. Paths are relative to the project directory. + /// The directory to put the DbContext file in. Paths are relative to the project directory. /// public static string ContextDirDescription => GetString("ContextDirDescription"); /// - /// The name of the DbContext. + /// The name of the DbContext. Defaults to the database name. /// public static string ContextNameDescription => GetString("ContextNameDescription"); /// - /// Specify to override the namespace for the DbContext class. + /// The namespace of the DbContext class. Defaults to match the directory. /// public static string ContextNamespaceDescription => GetString("ContextNamespaceDescription"); @@ -164,6 +164,12 @@ public static string DbContextScaffoldDescription public static string DbContextScaffoldForceDescription => GetString("DbContextScaffoldForceDescription"); + /// + /// Generates a SQL script from the DbContext. Bypasses any migrations. + /// + public static string DbContextScriptDescription + => GetString("DbContextScriptDescription"); + /// /// Your startup project '{startupProject}' doesn't reference Microsoft.EntityFrameworkCore.Design. This package is required for the Entity Framework Core Tools to work. Ensure your startup project is correct, install the package, and try again. /// @@ -193,7 +199,7 @@ public static string InvalidTemplatePattern([CanBeNull] object template) template); /// - /// Show JSON output. + /// Show JSON output. Use with --prefix-output to parse programatically. /// public static string JsonDescription => GetString("JsonDescription"); @@ -255,13 +261,13 @@ public static string MigrationsListDescription => GetString("MigrationsListDescription"); /// - /// Specify to override the namespace for the migration. + /// The namespace to use. Defaults to match the directory. /// public static string MigrationsNamespaceDescription => GetString("MigrationsNamespaceDescription"); /// - /// The directory (and sub-namespace) to use. Paths are relative to the project directory. Defaults to "Migrations". + /// The directory to put files in. Paths are relative to the project directory. Defaults to "Migrations". /// public static string MigrationsOutputDirDescription => GetString("MigrationsOutputDirDescription"); @@ -285,7 +291,7 @@ public static string MigrationsScriptDescription => GetString("MigrationsScriptDescription"); /// - /// The ending migration. Defaults to the last migration. + /// The target migration. Defaults to the last migration. /// public static string MigrationToDescription => GetString("MigrationToDescription"); @@ -307,7 +313,7 @@ public static string MissingOption([CanBeNull] object option) option); /// - /// Specify to override the namespace for the generated entity types. + /// The namespace to use. Defaults to match the directory. /// public static string NamespaceDescription => GetString("NamespaceDescription"); @@ -381,7 +387,7 @@ public static string PrefixDescription => GetString("PrefixDescription"); /// - /// The project directory. Defaults to the current directory. + /// The project directory. Defaults to the current working directory. /// public static string ProjectDirDescription => GetString("ProjectDirDescription"); @@ -435,7 +441,7 @@ public static string StartupAssemblyDescription => GetString("StartupAssemblyDescription"); /// - /// Suppress generation of the DbContext.OnConfiguring() method. + /// Don't generate DbContext.OnConfiguring. /// public static string SuppressOnConfiguringDescription => GetString("SuppressOnConfiguringDescription"); diff --git a/src/ef/Properties/Resources.resx b/src/ef/Properties/Resources.resx index 2a7431f067d..adda0a05081 100644 --- a/src/ef/Properties/Resources.resx +++ b/src/ef/Properties/Resources.resx @@ -118,7 +118,7 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - The assembly to use. + The assembly to use. Required. The connection string to the database. @@ -127,13 +127,13 @@ The DbContext to use. - The directory to put DbContext file in. Paths are relative to the project directory. + The directory to put the DbContext file in. Paths are relative to the project directory. - The name of the DbContext. + The name of the DbContext. Defaults to the database name. - Specify to override the namespace for the DbContext class. + The namespace of the DbContext class. Defaults to match the directory. Use attributes to configure the model (where possible). If omitted, only the fluent API is used. @@ -186,6 +186,9 @@ Overwrite existing files. + + Generates a SQL script from the DbContext. Bypasses any migrations. + Your startup project '{startupProject}' doesn't reference Microsoft.EntityFrameworkCore.Design. This package is required for the Entity Framework Core Tools to work. Ensure your startup project is correct, install the package, and try again. @@ -199,7 +202,7 @@ Invalid template pattern '{template}'. - Show JSON output. + Show JSON output. Use with --prefix-output to parse programatically. The language. Defaults to 'C#'. @@ -229,10 +232,10 @@ Lists available migrations. - Specify to override the namespace for the migration. + The namespace to use. Defaults to match the directory. - The directory (and sub-namespace) to use. Paths are relative to the project directory. Defaults to "Migrations". + The directory to put files in. Paths are relative to the project directory. Defaults to "Migrations". Removes the last migration. @@ -244,7 +247,7 @@ Generates a SQL script from migrations. - The ending migration. Defaults to the last migration. + The target migration. Defaults to the last migration. Missing required argument '{arg}'. @@ -253,7 +256,7 @@ Missing required option '--{option}'. - Specify to override the namespace for the generated entity types. + The namespace to use. Defaults to match the directory. Don't colorize output. @@ -289,7 +292,7 @@ Prefix output with level. - The project directory. Defaults to the current directory. + The project directory. Defaults to the current working directory. The provider to use. (E.g. Microsoft.EntityFrameworkCore.SqlServer) @@ -313,7 +316,7 @@ The startup assembly to use. Defaults to the target assembly. - Suppress generation of the DbContext.OnConfiguring() method. + Don't generate DbContext.OnConfiguring. The tables to generate entity types for. From 706ee28fd23d20b8cad4449d7b06fb04fc9ba317 Mon Sep 17 00:00:00 2001 From: Brice Lambson Date: Wed, 9 Sep 2020 16:28:26 -0700 Subject: [PATCH 2/4] Incorporating feedback on PR #22469 Auto-merge won. --- src/EFCore.Tools/tools/EntityFrameworkCore.PS2.psm1 | 6 +++--- src/EFCore.Tools/tools/EntityFrameworkCore.psm1 | 6 +++--- src/dotnet-ef/Properties/Resources.resx | 8 ++++---- src/ef/Properties/Resources.resx | 6 +++--- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/EFCore.Tools/tools/EntityFrameworkCore.PS2.psm1 b/src/EFCore.Tools/tools/EntityFrameworkCore.PS2.psm1 index 98f6177938c..fb7483d7267 100644 --- a/src/EFCore.Tools/tools/EntityFrameworkCore.PS2.psm1 +++ b/src/EFCore.Tools/tools/EntityFrameworkCore.PS2.psm1 @@ -26,7 +26,7 @@ $versionErrorMessage = 'The Entity Framework Core Package Manager Console Tools The startup project to use. Defaults to the solution's startup project. .PARAMETER Namespace - The namespace to use. Defaults to match the directory. + The namespace to use. Matches the directory by default. .PARAMETER Args Arguments passed to the application. @@ -244,10 +244,10 @@ function Remove-Migration( The startup project to use. Defaults to the solution's startup project. .PARAMETER Namespace - The namespace to use. Defaults to match the directory. + The namespace to use. Matches the directory by default. .PARAMETER ContextNamespace - The namespace of the DbContext class. Defaults to match the directory. + The namespace of the DbContext class. Matches the directory by default. .PARAMETER NoPluralize Don't use the pluralizer. diff --git a/src/EFCore.Tools/tools/EntityFrameworkCore.psm1 b/src/EFCore.Tools/tools/EntityFrameworkCore.psm1 index f7b91cb2c71..15768b20862 100644 --- a/src/EFCore.Tools/tools/EntityFrameworkCore.psm1 +++ b/src/EFCore.Tools/tools/EntityFrameworkCore.psm1 @@ -34,7 +34,7 @@ Register-TabExpansion Add-Migration @{ The startup project to use. Defaults to the solution's startup project. .PARAMETER Namespace - The namespace to use. Defaults to match the directory. + The namespace to use. Matches the directory by default. .PARAMETER Args Arguments passed to the application. @@ -424,10 +424,10 @@ Register-TabExpansion Scaffold-DbContext @{ The startup project to use. Defaults to the solution's startup project. .PARAMETER Namespace - The namespace to use. Defaults to match the directory. + The namespace to use. Matches the directory by default. .PARAMETER ContextNamespace - The namespace of the DbContext class. Defaults to match the directory. + The namespace of the DbContext class. Matches the directory by default. .PARAMETER NoPluralize Don't use the pluralizer. diff --git a/src/dotnet-ef/Properties/Resources.resx b/src/dotnet-ef/Properties/Resources.resx index cfc60c7be89..b8299f07e9f 100644 --- a/src/dotnet-ef/Properties/Resources.resx +++ b/src/dotnet-ef/Properties/Resources.resx @@ -142,7 +142,7 @@ The name of the DbContext. Defaults to the database name. - The namespace of the DbContext class. Defaults to match the directory. + The namespace of the DbContext class. Matches the directory by default. Use attributes to configure the model (where possible). If omitted, only the fluent API is used. @@ -226,7 +226,7 @@ Lists available migrations. - The namespace to use. Defaults to match the directory. + The namespace to use. Matches the directory by default. The directory to put files in. Paths are relative to the project directory. Defaults to "Migrations". @@ -253,7 +253,7 @@ More than one project was found in the current working directory. Use the --startup-project option. - The namespace to use. Defaults to match the directory. + The namespace to use. Matches the directory by default. Startup project '{startupProject}' targets framework '.NETCoreApp' version '{targetFrameworkVersion}'. This version of the Entity Framework Core .NET Command-line Tools only supports version 2.0 or higher. For information on using older versions of the tools, see https://go.microsoft.com/fwlink/?linkid=871254 @@ -262,7 +262,7 @@ Startup project '{startupProject}' targets framework '.NETStandard'. There is no runtime associated with this framework, and projects targeting it cannot be executed directly. To use the Entity Framework Core .NET Command-line Tools with this project, add an executable project targeting .NET Core or .NET Framework that references this project, and set it as the startup project using --startup-project; or, update this project to cross-target .NET Core or .NET Framework. For more information on using the Entity Framework Tools with .NET Standard projects, see https://go.microsoft.com/fwlink/?linkid=2034781 - Don't build the project. Only use when the build is up-to-date. + Don't build the project. Intended to be used when the build is up-to-date. Don't colorize output. diff --git a/src/ef/Properties/Resources.resx b/src/ef/Properties/Resources.resx index adda0a05081..7805fcb86ba 100644 --- a/src/ef/Properties/Resources.resx +++ b/src/ef/Properties/Resources.resx @@ -133,7 +133,7 @@ The name of the DbContext. Defaults to the database name. - The namespace of the DbContext class. Defaults to match the directory. + The namespace of the DbContext class. Matches the directory by default. Use attributes to configure the model (where possible). If omitted, only the fluent API is used. @@ -232,7 +232,7 @@ Lists available migrations. - The namespace to use. Defaults to match the directory. + The namespace to use. Matches the directory by default. The directory to put files in. Paths are relative to the project directory. Defaults to "Migrations". @@ -256,7 +256,7 @@ Missing required option '--{option}'. - The namespace to use. Defaults to match the directory. + The namespace to use. Matches the directory by default. Don't colorize output. From 69ce8af8c2b7ac90fc54798ea206d3770fb8db43 Mon Sep 17 00:00:00 2001 From: Andriy Svyryd Date: Wed, 9 Sep 2020 18:28:01 -0700 Subject: [PATCH 3/4] Remove extra ToList calls in MigrationsModelDiffer --- .../Migrations/Internal/MigrationsModelDiffer.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/EFCore.Relational/Migrations/Internal/MigrationsModelDiffer.cs b/src/EFCore.Relational/Migrations/Internal/MigrationsModelDiffer.cs index 73291ab01b6..ed91236f62e 100644 --- a/src/EFCore.Relational/Migrations/Internal/MigrationsModelDiffer.cs +++ b/src/EFCore.Relational/Migrations/Internal/MigrationsModelDiffer.cs @@ -304,7 +304,7 @@ protected virtual IReadOnlyList Sort( } } - createTableOperations = createTableGraph.TopologicalSort( + createTableOperations = (List)createTableGraph.TopologicalSort( (principalCreateTableOperation, createTableOperation, cyclicAddForeignKeyOperations) => { foreach (var cyclicAddForeignKeyOperation in cyclicAddForeignKeyOperations) @@ -321,7 +321,7 @@ protected virtual IReadOnlyList Sort( } return true; - }).ToList(); + }); var dropTableGraph = new Multigraph(); dropTableGraph.AddVertices(dropTableOperations); @@ -340,13 +340,13 @@ protected virtual IReadOnlyList Sort( } var newDiffContext = new DiffContext(); - dropTableOperations = dropTableGraph.TopologicalSort( + dropTableOperations = (List)dropTableGraph.TopologicalSort( (dropTableOperation, principalDropTableOperation, foreignKeys) => { dropForeignKeyOperations.AddRange(foreignKeys.SelectMany(c => Remove(c, newDiffContext))); return true; - }).ToList(); + }); return dropForeignKeyOperations .Concat(dropTableOperations) @@ -429,7 +429,6 @@ private IEnumerable DiffAnnotations( IRelationalModel source, IRelationalModel target) { - var sourceMigrationsAnnotations = source?.GetAnnotations().ToList(); var targetMigrationsAnnotations = target?.GetAnnotations().ToList(); if (source == null) @@ -446,17 +445,18 @@ private IEnumerable DiffAnnotations( if (target == null) { - sourceMigrationsAnnotations = MigrationsAnnotations.ForRemove(source).ToList(); - if (sourceMigrationsAnnotations.Count > 0) + var sourceMigrationsAnnotationsForRemoved = MigrationsAnnotations.ForRemove(source).ToList(); + if (sourceMigrationsAnnotationsForRemoved.Count > 0) { var alterDatabaseOperation = new AlterDatabaseOperation(); - alterDatabaseOperation.OldDatabase.AddAnnotations(sourceMigrationsAnnotations); + alterDatabaseOperation.OldDatabase.AddAnnotations(sourceMigrationsAnnotationsForRemoved); yield return alterDatabaseOperation; } yield break; } + var sourceMigrationsAnnotations = source?.GetAnnotations().ToList(); if (HasDifferences(sourceMigrationsAnnotations, targetMigrationsAnnotations)) { var alterDatabaseOperation = new AlterDatabaseOperation(); From 77c16b4f867a573fd514498792174742727f0132 Mon Sep 17 00:00:00 2001 From: Arthur Vickers Date: Thu, 10 Sep 2020 07:35:50 -0700 Subject: [PATCH 4/4] Generate conditionals instead of switch in materializer delegate for discriminator values that need custom comparison (#22470) Part of #19650 --- src/EFCore/Query/EntityShaperExpression.cs | 40 ++++++++++--------- .../Internal/StaticDiscriminatorComparer.cs | 35 ---------------- 2 files changed, 21 insertions(+), 54 deletions(-) delete mode 100644 src/EFCore/Query/Internal/StaticDiscriminatorComparer.cs diff --git a/src/EFCore/Query/EntityShaperExpression.cs b/src/EFCore/Query/EntityShaperExpression.cs index 280db9e2661..937d7199ffe 100644 --- a/src/EFCore/Query/EntityShaperExpression.cs +++ b/src/EFCore/Query/EntityShaperExpression.cs @@ -111,13 +111,6 @@ protected virtual LambdaExpression GenerateMaterializationCondition([NotNull] IE discriminatorProperty.ClrType, discriminatorProperty.GetIndex(), discriminatorProperty)) }; - var switchCases = new SwitchCase[concreteEntityTypes.Length]; - for (var i = 0; i < concreteEntityTypes.Length; i++) - { - var discriminatorValue = Constant(concreteEntityTypes[i].GetDiscriminatorValue(), discriminatorProperty.ClrType); - switchCases[i] = SwitchCase(Constant(concreteEntityTypes[i], typeof(IEntityType)), discriminatorValue); - } - var exception = Block( Throw( Call( @@ -125,26 +118,35 @@ protected virtual LambdaExpression GenerateMaterializationCondition([NotNull] IE Convert(discriminatorValueVariable, typeof(object)))), Constant(null, typeof(IEntityType))); - var discriminatorComparer = discriminatorProperty.GetKeyValueComparer(); if (discriminatorComparer.IsDefault()) { + var switchCases = new SwitchCase[concreteEntityTypes.Length]; + for (var i = 0; i < concreteEntityTypes.Length; i++) + { + var discriminatorValue = Constant(concreteEntityTypes[i].GetDiscriminatorValue(), discriminatorProperty.ClrType); + switchCases[i] = SwitchCase(Constant(concreteEntityTypes[i], typeof(IEntityType)), discriminatorValue); + } + expressions.Add(Switch(discriminatorValueVariable, exception, switchCases)); } else { - var staticComparer = typeof(StaticDiscriminatorComparer<,,>).MakeGenericType( - discriminatorProperty.DeclaringEntityType.ClrType, - discriminatorProperty.ClrType, - discriminatorProperty.GetTypeMapping().Converter.ProviderClrType); - - var comparerField = staticComparer.GetField(nameof(StaticDiscriminatorComparer.Comparer)); - comparerField.SetValue(null, discriminatorComparer); - - var equalsMethod = staticComparer.GetMethod(nameof(StaticDiscriminatorComparer.DiscriminatorEquals)); - expressions.Add(Switch(discriminatorValueVariable, exception, equalsMethod, switchCases)); + Expression conditions = exception; + for (var i = concreteEntityTypes.Length - 1; i >= 0; i--) + { + conditions = Condition( + discriminatorComparer.ExtractEqualsBody( + discriminatorValueVariable, + Constant( + concreteEntityTypes[i].GetDiscriminatorValue(), + discriminatorProperty.ClrType)), + Constant(concreteEntityTypes[i], typeof(IEntityType)), + conditions); + } + + expressions.Add(conditions); } - body = Block(new[] { discriminatorValueVariable }, expressions); } else diff --git a/src/EFCore/Query/Internal/StaticDiscriminatorComparer.cs b/src/EFCore/Query/Internal/StaticDiscriminatorComparer.cs deleted file mode 100644 index 21c87e3b17c..00000000000 --- a/src/EFCore/Query/Internal/StaticDiscriminatorComparer.cs +++ /dev/null @@ -1,35 +0,0 @@ -// 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 JetBrains.Annotations; -using Microsoft.EntityFrameworkCore.ChangeTracking; - -namespace Microsoft.EntityFrameworkCore.Query.Internal -{ - /// - /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to - /// the same compatibility standards as public APIs. It may be changed or removed without notice in - /// any release. You should only use it directly in your code with extreme caution and knowing that - /// doing so can result in application failures when updating to a new Entity Framework Core release. - /// - // ReSharper disable twice UnusedTypeParameter - public static class StaticDiscriminatorComparer - { - /// - /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to - /// the same compatibility standards as public APIs. It may be changed or removed without notice in - /// any release. You should only use it directly in your code with extreme caution and knowing that - /// doing so can result in application failures when updating to a new Entity Framework Core release. - /// - public static ValueComparer Comparer; - - /// - /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to - /// the same compatibility standards as public APIs. It may be changed or removed without notice in - /// any release. You should only use it directly in your code with extreme caution and knowing that - /// doing so can result in application failures when updating to a new Entity Framework Core release. - /// - public static bool DiscriminatorEquals([CanBeNull] TModel x, [CanBeNull] TModel y) - => Comparer.Equals(x, y); - } -}