Skip to content

Bug Report: MissingMethodException with FindDiscriminatorProperty() When Upgrade Project To .Net 10 Version #125

@BilalSakaiTech

Description

@BilalSakaiTech

System.MissingMethodException: Method not found: 'Microsoft.EntityFrameworkCore.Metadata.IProperty Microsoft.EntityFrameworkCore.Metadata.IEntityType.FindDiscriminatorProperty()'.
at Detached.Mappers.EntityFramework.Conventions.EntityTypeConventions.SetDiscriminator(ClassType classType, IEntityType entityType)
at Detached.Mappers.EntityFramework.Conventions.EntityTypeConventions.Apply(MapperOptions mapperOptions, IType type)
at Detached.Mappers.Options.MapperOptions.ApplyAnnotations(IType type)

Environment

Detached Mapper Version: [9.0.2]
Entity Framework Core Version: [10.0.0]
Npgsql.EntityFrameworkCore.PostgreSQL Version: [10.0.0]
.NET Version: [10.0.0]
Database Provider: PostgreSQL (Npgsql)

Code Sample
Program.cs Configuration:
csharpbuilder.Services
.AddDbContext(options =>
options.UseNpgsql(
builder.Configuration.GetConnectionString("DefaultConnection"),
sqlServerOptions =>
{
sqlServerOptions.EnableRetryOnFailure(
maxRetryCount: 5,
maxRetryDelay: TimeSpan.FromSeconds(30),
errorCodesToAdd: null
);
}
)
.UseMapping()
);

Service Code:
csharppublic async Task SaveCategory(CategorySaveVM vm)
{
var category = await context.MapAsync(vm);
context.Categories.Add(category);
await context.SaveChangesAsync();

return category.Id;

}
Controller Code:
csharp[HttpPost]
public async Task SaveCategory(CategorySaveVM categoryVM)
{
if (categoryVM.Id == 0)
{
var id = await service.SaveCategory(categoryVM);
return Ok(new { id });
}

var result = await service.UpdateCategory(categoryVM);

if (result.FirstError.Type == ErrorType.NotFound)
    return NotFound(result.FirstError.Description);

return Ok(new { id = result.Value });

}

Steps to Reproduce

Install latest Detached.Mappers.EntityFrameworkCore package
Configure DbContext with .UseMapping() extension
Attempt to use context.MapAsync(viewModel)
Exception is thrown during mapping

Expected Behavior
The mapper should successfully map the ViewModel to the Entity without throwing a MissingMethodException.
Actual Behavior
A MissingMethodException is thrown indicating that the FindDiscriminatorProperty() method cannot be found on IEntityType.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions