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();
}
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.
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();
}
Controller Code:
csharp[HttpPost]
public async Task SaveCategory(CategorySaveVM categoryVM)
{
if (categoryVM.Id == 0)
{
var id = await service.SaveCategory(categoryVM);
return Ok(new { id });
}
}
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.