dotnet / efcore

EF Core is a modern object-database mapper for .NET. It supports LINQ queries, change tracking, updates, and schema migrations.
https://docs.microsoft.com/ef/
MIT License
13.65k stars 3.15k forks source link

dotnet ef dbcontext scaffold not creating files on Mac #23660

Closed psantos10 closed 1 year ago

psantos10 commented 3 years ago

Description

1- On MacOS Big Sur v 11.0.1, using VS Code, I created a classlib project. Into that project, I referenced two packages:

2- I generated a SQLite Database (Northwind.db):

Northwind.db.zip

3- I run the following command to generate the Entity Classes:

dotnet ef dbcontext scaffold "Filename=../Northwind.db" Microsoft.EntityFrameworkCore.Sqlite --namespace Packt.Shared --data-annotations --context Northwind

Few seconds later I get this ouput:

Build started... Build succeeded. To protect potentially sensitive information in your connection string, you should move it out of source code. You can avoid scaffolding the connection string by using the Name= syntax to read it from configuration - see https://go.microsoft.com/fwlink/?linkid=2131148. For more guidance on storing connection strings, see http://go.microsoft.com/fwlink/?LinkId=723263.

Expectation:

I was expected the Entity class files to be generated. But not file is created.

Include verbose output

dotnet ef dbcontext scaffold "Filename=../Northwind.db" Microsoft.EntityFrameworkCore.Sqlite --namespace Packt.Shared --data-annotations --context Northwind --verbose

Using project '/Users/psantos/Projects/Learning/dotNET/CSharp9dotNET5Code/PracticalApps/NorthwindEntitiesLib/NorthwindEntitiesLib.csproj'.
Using startup project '/Users/psantos/Projects/Learning/dotNET/CSharp9dotNET5Code/PracticalApps/NorthwindEntitiesLib/NorthwindEntitiesLib.csproj'.
Writing '/Users/psantos/Projects/Learning/dotNET/CSharp9dotNET5Code/PracticalApps/NorthwindEntitiesLib/obj/NorthwindEntitiesLib.csproj.EntityFrameworkCore.targets'...
dotnet msbuild /target:GetEFProjectMetadata /property:EFProjectMetadataFile=/var/folders/w6/w6j7wwq13xg81ls7cf65q86r0000gn/T/tmp54L1Db.tmp /verbosity:quiet /nologo /Users/psantos/Projects/Learning/dotNET/CSharp9dotNET5Code/PracticalApps/NorthwindEntitiesLib/NorthwindEntitiesLib.csproj
Writing '/Users/psantos/Projects/Learning/dotNET/CSharp9dotNET5Code/PracticalApps/NorthwindEntitiesLib/obj/NorthwindEntitiesLib.csproj.EntityFrameworkCore.targets'...
dotnet msbuild /target:GetEFProjectMetadata /property:EFProjectMetadataFile=/var/folders/w6/w6j7wwq13xg81ls7cf65q86r0000gn/T/tmpn2l1bZ.tmp /verbosity:quiet /nologo /Users/psantos/Projects/Learning/dotNET/CSharp9dotNET5Code/PracticalApps/NorthwindEntitiesLib/NorthwindEntitiesLib.csproj
Build started...
dotnet build /Users/psantos/Projects/Learning/dotNET/CSharp9dotNET5Code/PracticalApps/NorthwindEntitiesLib/NorthwindEntitiesLib.csproj /verbosity:quiet /nologo

Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:02.57
Build succeeded.
dotnet exec --depsfile /Users/psantos/Projects/Learning/dotNET/CSharp9dotNET5Code/PracticalApps/NorthwindEntitiesLib/bin/Debug/net5.0/NorthwindEntitiesLib.deps.json --additionalprobingpath /Users/psantos/.nuget/packages --runtimeconfig /Users/psantos/Projects/Learning/dotNET/CSharp9dotNET5Code/PracticalApps/NorthwindEntitiesLib/bin/Debug/net5.0/NorthwindEntitiesLib.runtimeconfig.json /Users/psantos/.dotnet/tools/.store/dotnet-ef/5.0.1/dotnet-ef/5.0.1/tools/netcoreapp3.1/any/tools/netcoreapp2.0/any/ef.dll dbcontext scaffold Filename=../Northwind.db Microsoft.EntityFrameworkCore.Sqlite --namespace Packt.Shared --data-annotations --context Northwind --assembly /Users/psantos/Projects/Learning/dotNET/CSharp9dotNET5Code/PracticalApps/NorthwindEntitiesLib/bin/Debug/net5.0/NorthwindEntitiesLib.dll --startup-assembly /Users/psantos/Projects/Learning/dotNET/CSharp9dotNET5Code/PracticalApps/NorthwindEntitiesLib/bin/Debug/net5.0/NorthwindEntitiesLib.dll --project-dir /Users/psantos/Projects/Learning/dotNET/CSharp9dotNET5Code/PracticalApps/NorthwindEntitiesLib/ --language C# --working-dir /Users/psantos/Projects/Learning/dotNET/CSharp9dotNET5Code/PracticalApps/NorthwindEntitiesLib --verbose --root-namespace NorthwindEntitiesLib
Using assembly 'NorthwindEntitiesLib'.
Using startup assembly 'NorthwindEntitiesLib'.
Using application base '/Users/psantos/Projects/Learning/dotNET/CSharp9dotNET5Code/PracticalApps/NorthwindEntitiesLib/bin/Debug/net5.0'.
Using working directory '/Users/psantos/Projects/Learning/dotNET/CSharp9dotNET5Code/PracticalApps/NorthwindEntitiesLib'.
Using root namespace 'NorthwindEntitiesLib'.
Using project directory '/Users/psantos/Projects/Learning/dotNET/CSharp9dotNET5Code/PracticalApps/NorthwindEntitiesLib/'.
Remaining arguments: .
Finding design-time services for provider 'Microsoft.EntityFrameworkCore.Sqlite'...
Using design-time services from provider 'Microsoft.EntityFrameworkCore.Sqlite'.
Finding design-time services referenced by assembly 'NorthwindEntitiesLib'...
Finding design-time services referenced by assembly 'NorthwindEntitiesLib'...
No referenced design-time services were found.
Finding IDesignTimeServices implementations in assembly 'NorthwindEntitiesLib'...
No design-time services were found.
To protect potentially sensitive information in your connection string, you should move it out of source code. You can avoid scaffolding the connection string by using the Name= syntax to read it from configuration - see https://go.microsoft.com/fwlink/?linkid=2131148. For more guidance on storing connection strings, see http://go.microsoft.com/fwlink/?LinkId=723263.

Include provider and version information

EF Core version: 5.0.1 Database provider: (e.g. Microsoft.EntityFrameworkCore.Sqlite) Target framework: (e.g. .NET 5.0) Operating system: MacOS Big Sur v 11.0.1 IDE: Visual Studio Code 1.52.2

dotnet --info:

dotnet --info.NET SDK (reflecting any global.json):
 Version:   5.0.101
 Commit:    d05174dc5a

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  11.0
 OS Platform: Darwin
 RID:         osx.11.0-x64
 Base Path:   /usr/local/share/dotnet/sdk/5.0.101/

Host (useful for support):
  Version: 5.0.1
  Commit:  b02e13abab

.NET SDKs installed:
  3.1.403 [/usr/local/share/dotnet/sdk]
  5.0.100 [/usr/local/share/dotnet/sdk]
  5.0.101 [/usr/local/share/dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 3.1.9 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.0 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.1 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 3.1.9 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.0 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.1 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]

To install additional .NET runtimes or SDKs:
  https://aka.ms/dotnet-download
ajcvickers commented 3 years ago

@psantos10 Can you post your csproj file(s)?

psantos10 commented 3 years ago

@psantos10 Can you post your csproj file(s)?

@ajcvickers

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

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

  <ItemGroup>
    <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="5.0.1">
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
      <PrivateAssets>all</PrivateAssets>
    </PackageReference>
    <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="5.0.1" />
  </ItemGroup>

</Project>
smitpatel commented 3 years ago

I will try this out on mac this afternoon.

smitpatel commented 3 years ago

I am not able repro this. It generates entity/db context files correctly for me. One possible issue could be, you are passing the databaes file name using file path. Does the file exist in right location? I put the db file in same directory as csproj file and used "FileName=Northwind.db" as connection string.

psantos10 commented 3 years ago

I am not able repro this. It generates entity/db context files correctly for me. One possible issue could be, you are passing the databaes file name using file path. Does the file exist in right location? I put the db file in same directory as csproj file and used "FileName=Northwind.db" as connection string.

Yes, the file exists. Creating Entity/db Context files manually, I can retrieve the data from Database, I can do a CRUD.

Actually, right now, I am using the project, But I had to create the entities/db context manually.

ajcvickers commented 3 years ago

@psantos10 I don't think there is anything else we can do here without being able to reproduce the issue.

ajcvickers commented 3 years ago

EF Team Triage: Closing this issue as the requested additional details have not been provided and we have been unable to reproduce it.

BTW this is a canned response and may have info or details that do not directly apply to this particular issue. While we'd like to spend the time to uniquely address every incoming issue, we get a lot traffic on the EF projects and that is not practical. To ensure we maximize the time we have to work on fixing bugs, implementing new features, etc. we use canned responses for common triage decisions.