I've just started to migrate to a SQL database and running into a problem with a MissingMethodException being thrown. Here is the configuration class that is throwing the error:
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Project.Core.Entities.Users;
namespace Project.Persistance.Configuration.Users
{
public class UserClaimTypeConfiguration : IEntityTypeConfiguration<UserClaimType>
{
public void Configure(EntityTypeBuilder<UserClaimType> builder)
{
builder.HasKey(entity => entity.Id);
builder.Property(entity => entity.Name)
.IsRequired()
.HasMaxLength(30);
builder.HasIndex(entity => entity.Name);
builder.Property(entity => entity.Description)
.IsRequired(false)
.HasMaxLength(100);
builder.Ignore(entity => entity.ValueType);
}
}
}
And this is error I am getting in the console:
PM> add-migration user
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.MissingMethodException: Method not found: 'Microsoft.EntityFrameworkCore.Metadata.Builders.IndexBuilder Microsoft.EntityFrameworkCore.Metadata.Builders.EntityTypeBuilder`1.HasIndex(System.Linq.Expressions.Expression`1<System.Func`2<!0,System.Object>>)'.
at Project.Persistance.Configuration.Users.UserClaimTypeConfiguration.Configure(EntityTypeBuilder`1 builder)
at Microsoft.EntityFrameworkCore.ModelBuilder.ApplyConfiguration[TEntity](IEntityTypeConfiguration`1 configuration)
I've tried 'Goggle' and the Microsoft docs but can't seem to find any reference to this issue - so it must be my setup. Just can't figure out what is causing it!
Breaking change in .NET Core 3.0 preview 3. Fixed in preview 4: ASP.NET Core Issue 8467 (RESOLVED)