Skip to content

The dotnet ef dbcontext scaffold command does not print all expected logs #26384

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
0xced opened this issue Oct 17, 2021 · 4 comments
Closed

Comments

@0xced
Copy link
Contributor

0xced commented Oct 17, 2021

This is a regression from EF Core 5.

With .NET 5 / EF Core 5

.config/dotnet-tools.json

{
  "version": 1,
  "isRoot": true,
  "tools": {
    "dotnet-ef": {
      "version": "5.0.11",
      "commands": [
        "dotnet-ef"
      ]
    }
  }
}

ef5scaffold.csproj

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>net5.0</TargetFramework>
    <Nullable>enable</Nullable>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="5.0.11" PrivateAssets="all" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="5.0.11" />
  </ItemGroup>

</Project>

global.json

{
  "sdk": {
    "version": "5.0.402"
  }
}
$ dotnet --version
5.0.402
$ dotnet ef --version
Entity Framework Core .NET Command-line Tools
5.0.11

Running dotnet ef dbcontext scaffold --verbose --no-onconfiguring "Server=sqlprosample.database.windows.net;Database=sqlprosample;User=sqlproro;Password=nh{Zd?*8ZU@Y}Bb#" Microsoft.EntityFrameworkCore.SqlServer prints many verbose logs. This is the expected behaviour.

Using assembly 'ef5scaffold'.
Using startup assembly 'ef5scaffold'.
Using application base '~/Projects/Experiments/ef5scaffold/bin/Debug/net5.0'.
Using working directory '~/Projects/Experiments/ef5scaffold'.
Using root namespace 'ef5scaffold'.
Using project directory '~/Projects/Experiments/ef5scaffold/'.
Remaining arguments: .
Finding design-time services for provider 'Microsoft.EntityFrameworkCore.SqlServer'...
Using design-time services from provider 'Microsoft.EntityFrameworkCore.SqlServer'.
Finding design-time services referenced by assembly 'ef5scaffold'...
Finding design-time services referenced by assembly 'ef5scaffold'...
No referenced design-time services were found.
Finding IDesignTimeServices implementations in assembly 'ef5scaffold'...
No design-time services were found.
Found default schema 'dbo'.
Found type alias with name: sys.sysname which maps to underlying data type nvarchar(128).
Found table with name: dbo.BuildVersion.
Found table with name: dbo.ErrorLog.
Found table with name: dbo.towns.
Found table with name: SalesLT.Address.
Found table with name: SalesLT.Customer.
Found table with name: SalesLT.CustomerAddress.
Found table with name: SalesLT.Product.
Found table with name: SalesLT.ProductCategory.
Found table with name: SalesLT.ProductDescription.
Found table with name: SalesLT.ProductModel.
Found table with name: SalesLT.ProductModelProductDescription.
Found table with name: SalesLT.SalesOrderDetail.
Found table with name: SalesLT.SalesOrderHeader.
Found table with name: SalesLT.vGetAllCategories.
Found table with name: SalesLT.vProductAndDescription.
Found table with name: SalesLT.vProductModelCatalogDescription.
Found column with table: dbo.BuildVersion, column name: SystemInformationID, ordinal: 1, data type: sys.tinyint, maximum length: 1, precision: 3, scale: 0, nullable: False, identity: True, default value: (null), computed value: (null), computed value is stored: False
Found column with table: dbo.BuildVersion, column name: Database Version, ordinal: 2, data type: sys.nvarchar, maximum length: 50, precision: 0, scale: 0, nullable: False, identity: False, default value: (null), computed value: (null), computed value is stored: False
Found column with table: dbo.BuildVersion, column name: VersionDate, ordinal: 3, data type: sys.datetime, maximum length: 8, precision: 23, scale: 3, nullable: False, identity: False, default value: (null), computed value: (null), computed value is stored: False
Found column with table: dbo.BuildVersion, column name: ModifiedDate, ordinal: 4, data type: sys.datetime, maximum length: 8, precision: 23, scale: 3, nullable: False, identity: False, default value: (null), computed value: (null), computed value is stored: False
[…]

With .NET 6 / EF Core 6

.config/dotnet-tools.json

{
  "version": 1,
  "isRoot": true,
  "tools": {
    "dotnet-ef": {
      "version": "6.0.0-rc.2.21480.5",
      "commands": [
        "dotnet-ef"
      ]
    }
  }
}

ef6scaffold.csproj

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>net6.0</TargetFramework>
    <Nullable>enable</Nullable>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.0-rc.2.21480.5" PrivateAssets="all" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.0-rc.2.21480.5" />
  </ItemGroup>

</Project>

global.json

{
  "sdk": {
    "version": "6.0.100-rc.2.21505.57"
  }
}
$ dotnet --version
6.0.100-rc.2.21505.57
$ dotnet ef --version
Entity Framework Core .NET Command-line Tools
6.0.0-rc.2.21480.5

Running the same command dotnet ef dbcontext scaffold --verbose --no-onconfiguring "Server=sqlprosample.database.windows.net;Database=sqlprosample;User=sqlproro;Password=nh{Zd?*8ZU@Y}Bb#" Microsoft.EntityFrameworkCore.SqlServer does not print verbose logs anymore. Here is the full output:

Using assembly 'ef6scaffold'.
Using startup assembly 'ef6scaffold'.
Using application base '~/Projects/Experiments/ef6scaffold/bin/Debug/net6.0'.
Using working directory '~/Projects/Experiments/ef6scaffold'.
Using root namespace 'ef6scaffold'.
Using project directory '~/Projects/Experiments/ef6scaffold/'.
Remaining arguments: .
Finding design-time services referenced by assembly 'ef6scaffold'...
Finding design-time services referenced by assembly 'ef6scaffold'...
No referenced design-time services were found.
Finding design-time services for provider 'Microsoft.EntityFrameworkCore.SqlServer'...
Using design-time services from provider 'Microsoft.EntityFrameworkCore.SqlServer'.
Finding IDesignTimeServices implementations in assembly 'ef6scaffold'...
No design-time services were found.

All the Found default schema, Found table, Found column with table, Found primary key with name are not printed anymore at all.

Also, scaffolding on this particular database should produce warnings (see #25729 and #25748) but they are not printed at all, regardless of the --verbose option. It looks like the many different logging/diagnostics/reporter components at play during scaffolding are not properly hooked together.

@ajcvickers
Copy link
Contributor

/cc @bricelam

@bricelam
Copy link
Contributor

Possibly related to the design-time services changes...

@ajcvickers
Copy link
Contributor

Note for triage: cofirmed this still repros with the latest daily build. Does look like it is due to service scoping changes, but haven't been able to pinpoint the issue.

@ajcvickers
Copy link
Contributor

FYI for those impacted by this issue: EF Core 6.0.1 is now available from NuGet.

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

4 participants