efcore icon indicating copy to clipboard operation
efcore copied to clipboard

Add-Migration Fails when targeting a network drive

Open Suzibandit opened this issue 2 years ago • 3 comments

Working through the RazorPages Tutorial (https://learn.microsoft.com/en-us/aspnet/core/tutorials/razor-pages/razor-pages-start?view=aspnetcore-7.0&tabs=visual-studio).

On page 2, after scaffolding, we need to create the database and intialise it with these two commands.

Add-Migration InitialCreate Update-Database

Fails saying it cannot find deps.json file even though file is there.

This fails on a Desktop with a redirected user profile. Works OK on a laptop without folder redirection.

I suspect the issue is that the path to the deps.json file is a URL and not to a drive letter.

Workaround was to install EF SDK 7.0 and run these equivilant commands

dotnet ef migrations add InitialCreate dotnet ef database update

EF Core version: 7.0 Database provider: (e.g. Microsoft.EntityFrameworkCore.SqlServer) Target framework: (e.g. .NET 7.0) Operating system: Windows 10 IDE: (e.g. Visual Studio 2022 17.4.4)

Suzibandit avatar Feb 02 '23 21:02 Suzibandit

@Suzibandit Can you post the -Verbose output from running the commands?

ajcvickers avatar Feb 09 '23 10:02 ajcvickers

Hi,

Here is the output from the Add-Migration step.

PM> Add-Migration InitialCreate -verbose Using project 'RazorPagesMovie2'. Using startup project 'RazorPagesMovie2'. Build started... Build succeeded. C:\Program Files\dotnet\dotnet.exe exec --depsfile "\\<share>\Users<user>\My Documents\Development\C#\RazorPagesMovie2\RazorPagesMovie2\bin\Debug\net7.0\RazorPagesMovie2.deps.json" --additionalprobingpath C:\Users\sblpn.nuget\packages --additionalprobingpath "C:\Program Files\dotnet\sdk\NuGetFallbackFolder" --runtimeconfig "\\<share>\Users<user>\My Documents\Development\C#\RazorPagesMovie2\RazorPagesMovie2\bin\Debug\net7.0\RazorPagesMovie2.runtimeconfig.json" C:\Users\sblpn.nuget\packages\microsoft.entityframeworkcore.tools\7.0.2\tools\netcoreapp2.0\any\ef.dll migrations add InitialCreate --json --verbose --no-color --prefix-output --assembly "\\<share>\Users<user>\My Documents\Development\C#\RazorPagesMovie2\RazorPagesMovie2\bin\Debug\net7.0\RazorPagesMovie2.dll" --project "\\<share>\Users<user>\My Documents\Development\C#\RazorPagesMovie2\RazorPagesMovie2\RazorPagesMovie2.csproj" --startup-assembly "\\<share>\Users<user>\My Documents\Development\C#\RazorPagesMovie2\RazorPagesMovie2\bin\Debug\net7.0\RazorPagesMovie2.dll" --startup-project "\\<share>\Users<user>\My Documents\Development\C#\RazorPagesMovie2\RazorPagesMovie2\RazorPagesMovie2.csproj" --project-dir "\\<share>\Users<user>\My Documents\Development\C#\RazorPagesMovie2\RazorPagesMovie2\" --language C# --configuration Debug --working-dir "Microsoft.PowerShell.Core\FileSystem::\\<share>\Users<user>\My Documents\Development\C#\RazorPagesMovie2" --root-namespace RazorPagesMovie2 --nullable The specified deps.json [\\<share>\Users<user>\My Documents\Development\C#\RazorPagesMovie2\RazorPagesMovie2\bin\Debug\net7.0\RazorPagesMovie2.deps.json] does not exist PM>

The file does exist.

I think

"\\<share>\Users<user>\My Documents\Development\C#\RazorPagesMovie2\RazorPagesMovie2\bin\Debug\net7.0\RazorPagesMovie2.deps.json"

should be

“\<share>\Users<user>\My Documents\Development\C#\RazorPagesMovie2\RazorPagesMovie2\bin\Debug\net7.0\RazorPagesMovie2.deps.json”

If I run the dotnet command with \\ changed to \ then I get this sensible looking output

verbose: Using assembly 'RazorPagesMovie2'. verbose: Using startup assembly 'RazorPagesMovie2'. verbose: Using application base '\SLD-NAS-001\FIS-D\Users\sblpn\My Documents\Development\C#\RazorPagesMovie2\RazorPagesMovie2\bin\Debug\net7.0'. verbose: Using working directory 'C:\WINDOWS\system32'. verbose: Using root namespace 'RazorPagesMovie2'. verbose: Using project directory '\SLD-NAS-001\FIS-D\Users\sblpn\My Documents\Development\C#\RazorPagesMovie2\RazorPagesMovie2'. verbose: Remaining arguments: . verbose: Finding DbContext classes... verbose: Finding IDesignTimeDbContextFactory implementations... verbose: Finding application service provider in assembly 'RazorPagesMovie2'... verbose: Finding Microsoft.Extensions.Hosting service provider... verbose: Using environment 'Development'. verbose: Using application service provider from Microsoft.Extensions.Hosting. verbose: Found DbContext 'RazorPagesMovie2Context'. verbose: Finding DbContext classes in the project... verbose: Using context 'RazorPagesMovie2Context'. warn: Microsoft.EntityFrameworkCore.Model.Validation[30000] No store type was specified for the decimal property 'Price' on entity type 'Movie'. This will cause values to be silently truncated if they do not fit in the default precision and scale. Explicitly specify the SQL server column type that can accommodate all the values in 'OnModelCreating' using 'HasColumnType', specify precision and scale using 'HasPrecision', or configure a value converter using 'HasConversion'. verbose: Finding design-time services referenced by assembly 'RazorPagesMovie2'... verbose: Finding design-time services referenced by assembly 'RazorPagesMovie2'... verbose: No referenced design-time services were found. verbose: Finding design-time services for provider 'Microsoft.EntityFrameworkCore.SqlServer'... verbose: Using design-time services from provider 'Microsoft.EntityFrameworkCore.SqlServer'. verbose: Finding IDesignTimeServices implementations in assembly 'RazorPagesMovie2'... verbose: No design-time services were found. warn: Microsoft.EntityFrameworkCore.Model.Validation[30000] No store type was specified for the decimal property 'Price' on entity type 'Movie'. This will cause values to be silently truncated if they do not fit in the default precision and scale. Explicitly specify the SQL server column type that can accommodate all the values in 'OnModelCreating' using 'HasColumnType', specify precision and scale using 'HasPrecision', or configure a value converter using 'HasConversion'. warn: No store type was specified for the decimal property 'Price' on entity type 'Movie'. This will cause values to be silently truncated if they do not fit in the default precision and scale. Explicitly specify the SQL server column type that can accommodate all the values in 'OnModelCreating' using 'HasColumnType', specify precision and scale using 'HasPrecision', or configure a value converter using 'HasConversion'. verbose: Writing migration to '\SLD-NAS-001\FIS-D\Users\sblpn\My Documents\Development\C#\RazorPagesMovie2\RazorPagesMovie2\Migrations\20230209124504_InitialCreate.cs'. verbose: Writing model snapshot to '\SLD-NAS-001\FIS-D\Users\sblpn\My Documents\Development\C#\RazorPagesMovie2\RazorPagesMovie2\Migrations\RazorPagesMovie2ContextModelSnapshot.cs'. data: { data: "migrationFile": "\\SLD-NAS-001\FIS-D\Users\sblpn\My Documents\Development\C#\RazorPagesMovie2\RazorPagesMovie2\Migrations\20230209124504_InitialCreate.cs", data: "metadataFile": "\\SLD-NAS-001\FIS-D\Users\sblpn\My Documents\Development\C#\RazorPagesMovie2\RazorPagesMovie2\Migrations\20230209124504_InitialCreate.Designer.cs", data: "snapshotFile": "\\SLD-NAS-001\FIS-D\Users\sblpn\My Documents\Development\C#\RazorPagesMovie2\RazorPagesMovie2\Migrations\RazorPagesMovie2ContextModelSnapshot.cs" data: }

So I think the problem is dealing with a “My Documents” folder that has been redirected to a network share.

Rgds/Pete

From: Arthur Vickers @.> Sent: 09 February 2023 10:55 To: dotnet/efcore @.> Cc: Suzibandit @.>; Mention @.> Subject: Re: [dotnet/efcore] RazorPagesMovie Migration Fails (Issue #30200)

@Suzibandithttps://github.com/Suzibandit Can you post the -Verbose output from running the commands?

— Reply to this email directly, view it on GitHubhttps://github.com/dotnet/efcore/issues/30200#issuecomment-1423993762, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AIUGQDGA2FCDICC6VAHS4BLWWTEJPANCNFSM6AAAAAAUPQIJEU. You are receiving this because you were mentioned.Message ID: @.@.>>

Suzibandit avatar Feb 09 '23 12:02 Suzibandit

Note from triage: this seems like a bug. Workaround is to map the network path to a drive letter.

ajcvickers avatar Feb 16 '23 17:02 ajcvickers