Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NpgsqlArrayConverter.ArrayConversionExpression throws IndexOutOfRangeException when using a custom derived type for the collection #3092

Open
PressXtoChris opened this issue Feb 14, 2024 · 3 comments

Comments

@PressXtoChris
Copy link

When using a custom derived class for a collection, the ArrayConversionExpression method throws an IndexOutOfRangeException when it attempts to get the (missing) generic type argument.

var iListType = typeof(IList<>).MakeGenericType(typeof(TInput).GetGenericArguments()[0]);

Example use case:

public class TestEntity(Guid id, CustomCollection values)
{
    public Guid Id { get; } = id;
    public CustomCollection Values { get; } = values;
}

public class CustomCollection : ReadOnlyCollection<string>
{
    public CustomCollection(string[] strings) : base(strings)
    {
        if (strings.Length == 0)
            throw new ArgumentException("At least one string must be provided", nameof(strings));
    }

    public bool SomeBusinessLogic() => this.Any(s => s.Contains("foo"));
}

public class TestDbContext : DbContext
{
    public DbSet<TestEntity> TestEntities { get; set; } = default!;
    public TestDbContext(DbContextOptions<TestDbContext> options) : base(options) { }

    protected override void OnModelCreating(ModelBuilder modelBuilder)
    {
        modelBuilder.Entity<TestEntity>()
            .ToTable("test_entities");

        modelBuilder.Entity<TestEntity>()
            .Property(x => x.Id)
            .HasColumnName("id");

        modelBuilder.Entity<TestEntity>()
            .PrimitiveCollection(x => x.Values)
            .HasColumnName("values")
            .ElementType()
            .HasConversion(typeof(CustomCollectionConversion));
    }
}

I think this could be resolved by getting the generic type arguments of the base class if TInput doesn't have any:

typeof(TInput).BaseType.GetGenericArguments()[0]
@roji roji added this to the 8.0.1 milestone Feb 14, 2024
@roji
Copy link
Member

roji commented Feb 14, 2024

Note to self: see also #3074 which may be related.

@roji
Copy link
Member

roji commented Feb 17, 2024

I can't reproduce the precise error, probably because the code above is partial (e.g. CustomCollectionConversion is missing); when reporting issues, please always include a fully runnable, minimal code sample so that nothing is missing.

What I do get is the following exception:

/Users/roji/projects/test/bin/Debug/net8.0/Test
Unhandled exception. System.InvalidOperationException: Converter for element type 'CustomCollection' cannot be used for 'TestEntity.Values' because its element type is 'string'.
   at Microsoft.EntityFrameworkCore.Metadata.Internal.ElementType.SetValueConverter(ValueConverter converter, ConfigurationSource configurationSource)
   at Microsoft.EntityFrameworkCore.Metadata.Internal.ElementType.SetValueConverter(Type converterType, ConfigurationSource configurationSource)
   at Microsoft.EntityFrameworkCore.Metadata.Internal.InternalElementTypeBuilder.HasConverter(Type converterType, ConfigurationSource configurationSource)
   at Microsoft.EntityFrameworkCore.Metadata.Builders.ElementTypeBuilder.HasConversion(Type conversionType)
   at BlogContext.OnModelCreating(ModelBuilder modelBuilder) in /Users/roji/projects/test/Program.cs:line 42

This error makes sense: you're doing HasConversion on the element type, rather than on the collection as a whole. changing the configuration to the following makes the program run without errors:

modelBuilder.Entity<TestEntity>()
    .PrimitiveCollection(x => x.Values)
    .HasColumnName("values")
    .Metadata.SetValueConverter(typeof(CustomCollectionConversion));
Full repro
await using var ctx = new BlogContext();
await ctx.Database.EnsureDeletedAsync();
await ctx.Database.EnsureCreatedAsync();

public class BlogContext : DbContext
{
    public DbSet<TestEntity> TestEntities { get; set; } = default!;

    protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        => optionsBuilder
            .UseNpgsql("Host=localhost;Username=test;Password=test")
            .LogTo(Console.WriteLine, LogLevel.Information)
            .EnableSensitiveDataLogging();

    protected override void OnModelCreating(ModelBuilder modelBuilder)
    {
        modelBuilder.Entity<TestEntity>()
            .ToTable("test_entities");

        modelBuilder.Entity<TestEntity>()
            .Property(x => x.Id)
            .HasColumnName("id");

        modelBuilder.Entity<TestEntity>()
            .PrimitiveCollection(x => x.Values)
            .HasColumnName("values")
            .Metadata.SetValueConverter(typeof(CustomCollectionConversion));

        // modelBuilder.Entity<TestEntity>()
        //     .PrimitiveCollection(x => x.Values)
        //     .HasColumnName("values")
        //     .ElementType()
        //     .HasConversion(typeof(CustomCollectionConversion));
    }

    public class CustomCollectionConversion()
        : ValueConverter<CustomCollection, string[]>(
            c => c.ToArray(),
            a => new CustomCollection(a));
}

public class Blog
{
    public int Id { get; set; }
    public string Name { get; set; }
}

public class TestEntity(Guid id, CustomCollection values)
{
    public Guid Id { get; } = id;
    public CustomCollection Values { get; } = values;
}

public class CustomCollection : ReadOnlyCollection<string>
{
    public CustomCollection(string[] strings) : base(strings)
    {
        if (strings.Length == 0)
            throw new ArgumentException("At least one string must be provided", nameof(strings));
    }

    public bool SomeBusinessLogic() => this.Any(s => s.Contains("foo"));
}

If this doesn't fix your problem in some way, can you please share a full, runnable repro (like the code just above) that shows the problem?

@roji roji removed this from the 8.0.1 milestone Feb 17, 2024
@PressXtoChris
Copy link
Author

PressXtoChris commented Feb 18, 2024

Apologies, didn't realise I'd left it off. My CustomCollection converter simply converted from string to string.

public class CustomCollectionConversion() : ValueConverter<string, string>(
    v => v,
    v => v);

Since using .HasConversion<string>() caused the following exception:

Unhandled exception. System.InvalidCastException: Unable to cast object of type 'System.String[]' to type 'NpgsqlArrayConversion.CustomCollection'.
   at lambda_method13(Closure, InternalEntityEntry)
   at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.InternalEntityEntry.OriginalValues..ctor(InternalEntityEntry entry)
   at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.InternalEntityEntry.EnsureOriginalValues()
   at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.InternalEntityEntrySubscriber.SnapshotAndSubscribe(InternalEntityEntry entry)
   at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.StartTracking(InternalEntityEntry entry)
   at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.InternalEntityEntry.SetEntityState(EntityState oldState, EntityState newState, Boolean acceptChanges, Boolean modifyProper
ties)
   at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.InternalEntityEntry.SetEntityState(EntityState entityState, Boolean acceptChanges, Boolean modifyProperties, Nullable`1 fo
rceStateWhenUnknownKey, Nullable`1 fallbackState)
   at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.EntityGraphAttacher.PaintAction(EntityEntryGraphNode`1 node)
   at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.EntityEntryGraphIterator.TraverseGraph[TState](EntityEntryGraphNode`1 node, Func`2 handleNode)
   at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.EntityGraphAttacher.AttachGraph(InternalEntityEntry rootEntry, EntityState targetState, EntityState storeGeneratedWithKeyS
etTargetState, Boolean forceStateWhenUnknownKey)
   at Microsoft.EntityFrameworkCore.Internal.InternalDbSet`1.SetEntityState(InternalEntityEntry entry, EntityState entityState)
   at Microsoft.EntityFrameworkCore.Internal.InternalDbSet`1.Add(TEntity entity)

Here's my full code:

Full repro of above Model.cs
using System.Collections.ObjectModel;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;

namespace NpgsqlArrayConversion;

public class TestEntity(Guid id, CustomCollection values)
{
    public Guid Id { get; } = id;
    public CustomCollection Values { get; } = values;

    private TestEntity() : this(default, default!) { }
}

public class CustomCollection : ReadOnlyCollection<string>
{
    public CustomCollection(string[] strings) : base(strings)
    {
        if (strings.Length == 0)
            throw new ArgumentException("At least one string must be provided", nameof(strings));
    }

    public bool SomeBusinessLogic() => this.Any(s => s.Contains("foo"));
}

public class TestDbContext : DbContext
{
    public DbSet<TestEntity> TestEntities { get; set; } = default!;
    public TestDbContext(DbContextOptions<TestDbContext> options) : base(options) { }

    protected override void OnModelCreating(ModelBuilder modelBuilder)
    {
        modelBuilder.Entity<TestEntity>()
            .ToTable("test_entities");

        modelBuilder.Entity<TestEntity>()
            .Property(x => x.Id)
            .HasColumnName("id");

        modelBuilder.Entity<TestEntity>()
            .PrimitiveCollection(x => x.Values)
            .HasColumnName("values")
            .ElementType()
            .HasConversion(typeof(CustomCollectionConversion));
    }
}

public class CustomCollectionConversion() : ValueConverter<string, string>(
    v => v,
    v => v);

public class TestDbContextFactory : IDesignTimeDbContextFactory<TestDbContext>
{
    public TestDbContext CreateDbContext(string[] args)
    {
        var optionsBuilder = new DbContextOptionsBuilder<TestDbContext>();
        optionsBuilder.UseNpgsql("Host=localhost;Database=postgres;Username=postgres;Password=password");
        return new TestDbContext(optionsBuilder.Options);
    }
}

Program.cs

using NpgsqlArrayConversion;

using var db = new TestDbContextFactory().CreateDbContext(Array.Empty<string>());

Console.WriteLine("Inserting a new item");

var strings = new[] { "One", "Two" };
db.TestEntities.Add(new TestEntity(Guid.NewGuid(), new CustomCollection(strings)));

db.SaveChanges();
Console.WriteLine("Saved");

Also worth noting that in my real-world use case, I've got a wrapper class for my strings:

Repro of real-world case Model.cs
using System.Collections.ObjectModel;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;

namespace NpgsqlArrayConversion;

public class TestEntity(Guid id, CustomCollection values)
{
    public Guid Id { get; } = id;
    public CustomCollection Values { get; } = values;

    private TestEntity() : this(default, default!) { }
}

public class CustomCollection : ReadOnlyCollection<StringWrapper>
{
    public CustomCollection(string[] strings) : base(strings.Select(StringWrapper.FromString).ToList())
    {
        if (strings.Length == 0)
            throw new ArgumentException("At least one string must be provided", nameof(strings));
    }

    public bool SomeBusinessLogic() => this.Any(s => s.Value.Contains("foo"));
}

public class StringWrapper
{
    public string Value { get; }
    private StringWrapper(string value) => Value = value;
    public static StringWrapper FromString(string value) => new(value);
}

public class TestDbContext : DbContext
{
    public DbSet<TestEntity> TestEntities { get; set; } = default!;
    public TestDbContext(DbContextOptions<TestDbContext> options) : base(options) { }

    protected override void OnModelCreating(ModelBuilder modelBuilder)
    {
        modelBuilder.Entity<TestEntity>()
            .ToTable("test_entities");

        modelBuilder.Entity<TestEntity>()
            .Property(x => x.Id)
            .HasColumnName("id");

        modelBuilder.Entity<TestEntity>()
            .PrimitiveCollection(x => x.Values)
            .HasColumnName("values")
            .ElementType()
            .HasConversion(typeof(StringWrapperConverter));
    }
}

public class StringWrapperConverter() : ValueConverter<StringWrapper, string>(
    v => v.Value,
    v => StringWrapper.FromString(v));

public class TestDbContextFactory : IDesignTimeDbContextFactory<TestDbContext>
{
    public TestDbContext CreateDbContext(string[] args)
    {
        var optionsBuilder = new DbContextOptionsBuilder<TestDbContext>();
        optionsBuilder.UseNpgsql("Host=localhost;Database=postgres;Username=postgres;Password=password");
        return new TestDbContext(optionsBuilder.Options);
    }
}

Program.cs

using NpgsqlArrayConversion;

using var db = new TestDbContextFactory().CreateDbContext(Array.Empty<string>());

Console.WriteLine("Inserting a new item");

var strings = new[] { "One", "Two" };
db.TestEntities.Add(new TestEntity(Guid.NewGuid(), new CustomCollection(strings)));

db.SaveChanges();
Console.WriteLine("Saved");

Using Microsoft.EntityFrameworkCore 8.0.2, and Ngpsql.EntityFrameworkCore.PostgreSQL 8.0.2

When I try the SetValueConverter implementation:

SetValueConverter implementation

Model.cs

using System.Collections.ObjectModel;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;

namespace NpgsqlArrayConversion;

public class TestEntity(Guid id, CustomCollection values)
{
    public Guid Id { get; } = id;
    public CustomCollection Values { get; } = values;

    private TestEntity() : this(default, default!) { }
}

public class CustomCollection : ReadOnlyCollection<StringWrapper>
{
    public CustomCollection(string[] strings) : base(strings.Select(StringWrapper.FromString).ToList())
    {
        if (strings.Length == 0)
            throw new ArgumentException("At least one string must be provided", nameof(strings));
    }

    public bool SomeBusinessLogic() => this.Any(s => s.Value.Contains("foo"));
}

public class StringWrapper
{
    public string Value { get; }

    private StringWrapper(string value) => Value = value;

    public static StringWrapper FromString(string value) => new(value);
}

public class TestDbContext : DbContext
{
    public DbSet<TestEntity> TestEntities { get; set; } = default!;
    public TestDbContext(DbContextOptions<TestDbContext> options) : base(options) { }

    protected override void OnModelCreating(ModelBuilder modelBuilder)
    {
        modelBuilder.Entity<TestEntity>()
            .ToTable("test_entities");

        modelBuilder.Entity<TestEntity>()
            .Property(x => x.Id)
            .HasColumnName("id");

        modelBuilder.Entity<TestEntity>()
            .PrimitiveCollection(x => x.Values)
            .HasColumnName("values")
            .Metadata.SetValueConverter(typeof(CustomCollectionConverter));
    }
}

public class CustomCollectionConverter() : ValueConverter<CustomCollection, string[]>(
    c => c.Select(x => x.Value).ToArray(),
    a => new CustomCollection(a));

public class TestDbContextFactory : IDesignTimeDbContextFactory<TestDbContext>
{
    public TestDbContext CreateDbContext(string[] args)
    {
        var optionsBuilder = new DbContextOptionsBuilder<TestDbContext>();
        optionsBuilder.UseNpgsql("Host=localhost;Database=postgres;Username=postgres;Password=password");
        return new TestDbContext(optionsBuilder.Options);
    }
}

Program.cs is the same as above

I get the following exception:

Unhandled exception. System.InvalidOperationException: The 'CustomCollection' property 'TestEntity.Values' could not be mapped because the database provider does not support this typ
e. Consider converting the property value to a type supported by the database using a value converter. See https://aka.ms/efcore-docs-value-converters for more information. Alternate
ly, exclude the property from the model using the '[NotMapped]' attribute or by using 'EntityTypeBuilder.Ignore' in 'OnModelCreating'.
   at Microsoft.EntityFrameworkCore.Infrastructure.ModelValidator.ThrowPropertyNotMappedException(String propertyType, IConventionTypeBase typeBase, IConventionProperty unmappedPrope
rty)
   at Microsoft.EntityFrameworkCore.Infrastructure.RelationalModelValidator.ThrowPropertyNotMappedException(String propertyType, IConventionTypeBase typeBase, IConventionProperty unm
appedProperty)
   at Microsoft.EntityFrameworkCore.Infrastructure.ModelValidator.<ValidatePropertyMapping>g__Validate|7_0(IConventionTypeBase typeBase, <>c__DisplayClass7_0&)
   at Microsoft.EntityFrameworkCore.Infrastructure.ModelValidator.ValidatePropertyMapping(IModel model, IDiagnosticsLogger`1 logger)
   at Microsoft.EntityFrameworkCore.Infrastructure.ModelValidator.Validate(IModel model, IDiagnosticsLogger`1 logger)
   at Microsoft.EntityFrameworkCore.Infrastructure.RelationalModelValidator.Validate(IModel model, IDiagnosticsLogger`1 logger)
   at Npgsql.EntityFrameworkCore.PostgreSQL.Infrastructure.Internal.NpgsqlModelValidator.Validate(IModel model, IDiagnosticsLogger`1 logger)
   at Microsoft.EntityFrameworkCore.Infrastructure.ModelRuntimeInitializer.Initialize(IModel model, Boolean designTime, IDiagnosticsLogger`1 validationLogger)
   at Microsoft.EntityFrameworkCore.Infrastructure.ModelSource.GetModel(DbContext context, ModelCreationDependencies modelCreationDependencies, Boolean designTime)
   at Microsoft.EntityFrameworkCore.Internal.DbContextServices.CreateModel(Boolean designTime)
   at Microsoft.EntityFrameworkCore.Internal.DbContextServices.get_Model()
   at Microsoft.EntityFrameworkCore.Infrastructure.EntityFrameworkServicesBuilder.<>c.<TryAddCoreServices>b__8_4(IServiceProvider p)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitFactory(FactoryCallSite factoryCallSite, RuntimeResolverContext context)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitCache(ServiceCallSite callSite, RuntimeResolverContext context, ServiceProviderEngineScope s
erviceProviderEngine, RuntimeResolverLock lockType)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScopeCache(ServiceCallSite callSite, RuntimeResolverContext context)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, RuntimeResolverContext context)        
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitCache(ServiceCallSite callSite, RuntimeResolverContext context, ServiceProviderEngineScope s
erviceProviderEngine, RuntimeResolverLock lockType)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScopeCache(ServiceCallSite callSite, RuntimeResolverContext context)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, RuntimeResolverContext context)        
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitCache(ServiceCallSite callSite, RuntimeResolverContext context, ServiceProviderEngineScope s
erviceProviderEngine, RuntimeResolverLock lockType)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScopeCache(ServiceCallSite callSite, RuntimeResolverContext context)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, RuntimeResolverContext context)        
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitCache(ServiceCallSite callSite, RuntimeResolverContext context, ServiceProviderEngineScope s
erviceProviderEngine, RuntimeResolverLock lockType)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScopeCache(ServiceCallSite callSite, RuntimeResolverContext context)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, RuntimeResolverContext context)        
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitCache(ServiceCallSite callSite, RuntimeResolverContext context, ServiceProviderEngineScope s
erviceProviderEngine, RuntimeResolverLock lockType)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScopeCache(ServiceCallSite callSite, RuntimeResolverContext context)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, RuntimeResolverContext context)        
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitCache(ServiceCallSite callSite, RuntimeResolverContext context, ServiceProviderEngineScope s
erviceProviderEngine, RuntimeResolverLock lockType)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScopeCache(ServiceCallSite callSite, RuntimeResolverContext context)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.Resolve(ServiceCallSite callSite, ServiceProviderEngineScope scope)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.DynamicServiceProviderEngine.<>c__DisplayClass2_0.<RealizeService>b__0(ServiceProviderEngineScope scope)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(ServiceIdentifier serviceIdentifier, ServiceProviderEngineScope serviceProviderEngineScope)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope.GetService(Type serviceType)
   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider)
   at Microsoft.EntityFrameworkCore.DbContext.get_DbContextDependencies()
   at Microsoft.EntityFrameworkCore.DbContext.get_ContextServices()
   at Microsoft.EntityFrameworkCore.DbContext.get_InternalServiceProvider()
   at Microsoft.EntityFrameworkCore.DbContext.get_DbContextDependencies()
   at Microsoft.EntityFrameworkCore.DbContext.Microsoft.EntityFrameworkCore.Internal.IDbContextDependencies.get_StateManager()
   at Microsoft.EntityFrameworkCore.Internal.InternalDbSet`1.EntryWithoutDetectChanges(TEntity entity)
   at Microsoft.EntityFrameworkCore.Internal.InternalDbSet`1.Add(TEntity entity)
at Program.<Main>$(String[] args) in \NpgsqlArrayConversion\Program.cs:line 10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants