Closed gawpat93 closed 10 months ago
@gawpat93 I'm going to need a minimal, runnable repro (console program) to be able to investigate this - a stack trace isn't enough.
Same issue here - I think the table names are now correct but Foreign Key names have changed.
EF migrations now just die with the above error
I'm seeing the same issue, and I made a short repro showing my scenario failing with 8.0.x.
In my case it seems to concern a one-to-one relationship where I define the principal entity first, including a nav property for the secondary entity. Then in the second entity, I define the relationship.
This used to work regardless of order, but now requires specific ordering.
Expected error in repro: Host can't be null
Actual error: The object has been removed from the model
Repro with top-level statements: Project.csproj
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="EFCore.NamingConventions" Version="8.0.1" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.0" />
</ItemGroup>
</Project>
Program.cs
using Microsoft.EntityFrameworkCore;
var optionsBuilder = new DbContextOptionsBuilder<DummyDbContext>()
.UseSnakeCaseNamingConvention()
.UseNpgsql();
using var dbContext = new DummyDbContext(optionsBuilder.Options);
dbContext.Database.Migrate();
public class DummyDbContext(DbContextOptions<DummyDbContext> options) : DbContext(options)
{
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<DummyPrincipal>();
modelBuilder.Entity<DummyOther>()
.HasOne(x => x.Principal)
.WithOne(x => x.Other)
.HasForeignKey<DummyOther>(x => x.PrincipalId);
}
}
public class DummyPrincipal
{
public long Id { get; set; }
public DummyOther Other { get; set; } = default!;
}
public class DummyOther
{
public long Id { get; set; }
public long PrincipalId { get; set; }
public DummyPrincipal Principal { get; set; } = default!;
}
Looking through the commit log there seem to have been a number of fairly significant code changes since rc2 - I think an rc3 would have been justified.
This was introduced in #244. I've pushed a fix and will release 8.0.2 momentarily.
Hello, I am using UseSnakeCaseNamingConvention with postgress. After migrating from version 8.0.0-rc.2 to 8.0.0 or 8.0.1 I am getting the error below when I am trying to access dbContext. I am not sure what could cause this issue.