question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Null Reference Exception when using HasData

See original GitHub issue

I have a quite complex project, with a separate migrations assembly, modular asp.net (orchard) project, database seeding and owned types. I was able to generate migrations with ef core 2.2, but am not longer able to do it with ef core 3. First thing I tried, after making it compile, was doing a migration, and got this stack trace

System.NullReferenceException: Object reference not set to an instance of an object. at lambda_method(Closure , ValueBuffer ) at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.InternalShadowEntityEntry…ctor(IStateManager stateManager, IEntityType entityType, ValueBuffer& valueBuffer) at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.InternalEntityEntryFactory.NewInternalEntityEntry(IStateManager stateManager, IEntityType entityType, Object entity, ValueBuffer& valueBuffer) at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.CreateEntry(IDictionary`2 values, IEntityType entityType) at Microsoft.EntityFrameworkCore.Migrations.Internal.MigrationsModelDiffer.TrackData(IModel source, IModel target) at Microsoft.EntityFrameworkCore.Migrations.Internal.MigrationsModelDiffer.Diff(IModel source, IModel target, DiffContext diffContext) at Microsoft.EntityFrameworkCore.Migrations.Internal.MigrationsModelDiffer.GetDifferences(IModel source, IModel 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) at Microsoft.EntityFrameworkCore.Design.OperationExecutor.AddMigrationImpl(String name, String outputDir, String contextType) 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.

The project is in this github repo

https://github.com/laguer71/Albatros

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:20 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
smitpatelcommented, Oct 15, 2019

It went into v 3.1.0-preview2. Would be available in nightly builds.

1reaction
VILLAN3LL3commented, Oct 15, 2019

@smitpatel Is there a workaround to get around this issue until your changes will be published?

Read more comments on GitHub >

github_iconTop Results From Across the Web

c# - Null Reference Exception on OnModelCreating using ...
Based on the exception details this seems like due to dependency injection. You should register DBContext in your startup. cs file as a...
Read more >
System.NullReferenceException message in creating ...
Hi everyone, I created a localdb sql server file(School.mdf) in the App_Data folder in an MVC project using .Net Framework 4.8.
Read more >
NullReferenceException occurs in XYSeries2D.cs when ...
NullReferenceException occurs in XYSeries2D.cs when Chart has data added to it but visibility is set to hidden.
Read more >
Array element returning null, but has data is assigned
I'm making an inventory system with drag and drop UI. The manager script has an array that contains the GameObjects of each InventorySlot...
Read more >
[Solved]-OnPropertyChanged triggering Null exception-wpf
Do anyone know why I'm getting Null exception error? A Null Reference Exception · Null Reference Exception was unhandled C# console application ·...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found