Describe the bugObject reference not set to an instance of an object when running second migration.
I think this is a problem for me specifically, but I have tried quite a lot of things and I am completely stuck, and it is blocking my usage of EF for F#.
I am using entity framework in an F# project (SAFE-stack) and I can create the initial migration, but when I try to do another migration it fails with a NullReferenceException.
I'm on a SAFE-template 3.1.1, but if I add entity framework to a new safe-template 3.1.1 it works fine. I suspect it is something wrong with my paket.lock, but I am not sure, and I have not had any success in fixing ut.
To Reproduce
I am not able to reproduce in a simpler project. I wonder if it could
Expected behavior
A new migration does not give me a an error.
Screenshots
❯ dotnet ef migrations add Test --verbose
Using project '/Users/espen/code/horus/src/Server/Server.fsproj'.
Using startup project '/Users/espen/code/horus/src/Server/Server.fsproj'.
Writing '/Users/espen/code/horus/src/Server/obj/Server.fsproj.EntityFrameworkCore.targets'...
dotnet msbuild /target:GetEFProjectMetadata /property:EFProjectMetadataFile=/var/folders/sb/g7_08qr135x_00vnhvz0hqqc0000gn/T/tmp509y63.tmp /verbosity:quiet /nologo /Users/espen/code/horus/src/Server/Server.fsproj
Writing '/Users/espen/code/horus/src/Server/obj/Server.fsproj.EntityFrameworkCore.targets'...
dotnet msbuild /target:GetEFProjectMetadata /property:EFProjectMetadataFile=/var/folders/sb/g7_08qr135x_00vnhvz0hqqc0000gn/T/tmp4U1rqW.tmp /verbosity:quiet /nologo /Users/espen/code/horus/src/Server/Server.fsproj
Build started...
dotnet build /Users/espen/code/horus/src/Server/Server.fsproj /verbosity:quiet /nologo
Build succeeded.
0 Warning(s)
0 Error(s)
Time Elapsed 00:00:13.26
Build succeeded.
dotnet exec --depsfile /Users/espen/code/horus/src/Server/bin/Debug/net5.0/Server.deps.json --additionalprobingpath /Users/espen/.nuget/packages --additionalprobingpath /usr/local/share/dotnet/sdk/NuGetFallbackFolder --runtimeconfig /Users/espen/code/horus/src/Server/bin/Debug/net5.0/Server.runtimeconfig.json /Users/espen/.nuget/packages/dotnet-ef/5.0.17/tools/netcoreapp3.1/any/tools/netcoreapp2.0/any/ef.dll migrations add Test --assembly /Users/espen/code/horus/src/Server/bin/Debug/net5.0/Server.dll --startup-assembly /Users/espen/code/horus/src/Server/bin/Debug/net5.0/Server.dll --project-dir /Users/espen/code/horus/src/Server/ --language F# --working-dir /Users/espen/code/horus/src/Server --verbose --root-namespace Server
Using assembly 'Server'.
Using startup assembly 'Server'.
Using application base '/Users/espen/code/horus/src/Server/bin/Debug/net5.0'.
Using working directory '/Users/espen/code/horus/src/Server'.
Using root namespace 'Server'.
Using project directory '/Users/espen/code/horus/src/Server/'.
Remaining arguments: .
Finding DbContext classes...
Finding IDesignTimeDbContextFactory implementations...
Finding application service provider in assembly 'Server'...
Finding Microsoft.Extensions.Hosting service provider...
No static method 'CreateHostBuilder(string[])' was found on class 'Program'.
No application service provider was found.
Finding DbContext classes in the project...
Found DbContext 'DataContext'.
Using context 'DataContext'.
Finding design-time services for provider 'Pomelo.EntityFrameworkCore.MySql'...
Using design-time services from provider 'Pomelo.EntityFrameworkCore.MySql'.
Finding design-time services referenced by assembly 'Server'...
Finding design-time services referenced by assembly 'Server'...
No referenced design-time services were found.
Finding IDesignTimeServices implementations in assembly 'Server'...
Using design-time services from class 'DesignTimeServices'.
'DataContext' disposed.
System.NullReferenceException: Object reference not set to an instance of an object.
at Microsoft.EntityFrameworkCore.Migrations.Internal.MigrationsModelDiffer.Initialize(ColumnOperation columnOperation, IColumn column, RelationalTypeMapping typeMapping, Boolean isNullable, IEnumerable`1 migrationsAnnotations, Boolean inline)
at Microsoft.EntityFrameworkCore.Migrations.Internal.MigrationsModelDiffer.Diff(IColumn source, IColumn target, DiffContext diffContext)+MoveNext()
at Pomelo.EntityFrameworkCore.MySql.Migrations.Internal.MySqlMigrationsModelDiffer.SkipRedundantCharSetSpecifyingAlterColumnOperations(IEnumerable`1 migrationOperations)+MoveNext()
at Pomelo.EntityFrameworkCore.MySql.Migrations.Internal.MySqlMigrationsModelDiffer.PostFilterOperations(IEnumerable`1 migrationOperations)+MoveNext()
at Microsoft.EntityFrameworkCore.Migrations.Internal.MigrationsModelDiffer.DiffCollection[T](IEnumerable`1 sources, IEnumerable`1 targets, DiffContext diffContext, Func`4 diff, Func`3 add, Func`3 remove, Func`4[] predicates)+MoveNext()
at System.Linq.Enumerable.ConcatIterator`1.MoveNext()
at Microsoft.EntityFrameworkCore.Migrations.Internal.MigrationsModelDiffer.Diff(ITable source, ITable target, DiffContext diffContext)+MoveNext()
at Pomelo.EntityFrameworkCore.MySql.Migrations.Internal.MySqlMigrationsModelDiffer.PostFilterOperations(IEnumerable`1 migrationOperations)+MoveNext()
at Microsoft.EntityFrameworkCore.Migrations.Internal.MigrationsModelDiffer.DiffCollection[T](IEnumerable`1 sources, IEnumerable`1 targets, DiffContext diffContext, Func`4 diff, Func`3 add, Func`3 remove, Func`4[] predicates)+MoveNext()
at System.Linq.Enumerable.ConcatIterator`1.MoveNext()
at Pomelo.EntityFrameworkCore.MySql.Migrations.Internal.MySqlMigrationsModelDiffer.PostFilterOperations(IEnumerable`1 migrationOperations)+MoveNext()
at Microsoft.EntityFrameworkCore.Migrations.Internal.MigrationsModelDiffer.Sort(IEnumerable`1 operations, DiffContext diffContext)
at Microsoft.EntityFrameworkCore.Migrations.Internal.MigrationsModelDiffer.GetDifferences(IRelationalModel source, IRelationalModel target)
at Microsoft.EntityFrameworkCore.Migrations.Design.MigrationsScaffolder.ScaffoldMigration(String migrationName, String rootNamespace, String subNamespace, String language)
at Microsoft.EntityFrameworkCore.Design.Internal.MigrationsOperations.AddMigration(String name, String outputDir, String contextType, String namespace)
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.AddMigrationImpl(String name, String outputDir, String contextType, String namespace)
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.AddMigration.<>c__DisplayClass0_0.<.ctor>b__0()
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.<>c__DisplayClass3_0`1.<Execute>b__0()
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action)
Object reference not set to an instance of an object.
Describe the bug
Object reference not set to an instance of an object
when running second migration.I think this is a problem for me specifically, but I have tried quite a lot of things and I am completely stuck, and it is blocking my usage of EF for F#.
I am using entity framework in an F# project (SAFE-stack) and I can create the initial migration, but when I try to do another migration it fails with a NullReferenceException.
I'm on a SAFE-template 3.1.1, but if I add entity framework to a new safe-template 3.1.1 it works fine. I suspect it is something wrong with my paket.lock, but I am not sure, and I have not had any success in fixing ut.
To Reproduce I am not able to reproduce in a simpler project. I wonder if it could
Expected behavior A new migration does not give me a an error.
Screenshots
My paket.lock file locks looks like this: