Skip to content

Can't map user-defined range with subtype StoreType when the subtype type is plugin-provided #688

@shoooe

Description

@shoooe

I've attempted to use the new custom range type support with LocalTime (from NodaTime).

So I've set it up with:

            services.AddDbContext<MainContext>(options => 
                options.UseNpgsql(
                    Configuration.GetConnectionString("MainContext"),
                    opts => 
                    {
                        opts.UseNodaTime();
                        opts.MapRange<LocalTime>("timerange");
                    }));

and:

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.ForNpgsqlHasRange("timerange", "time");
            // ...
        }

Then in one of my model classes I've put:

public NpgsqlRange<LocalTime> Period { get; set; }

Then I ran:

dotnet ef migrations add Initial

and I get:

System.TypeLoadException: Could not load type 'Npgsql.EntityFrameworkCore.PostgreSQL.Storage.Internal.Mapping.NpgsqlRangeTypeMapping`1' from assembly 'Npgsql.EntityFrameworkCore.PostgreSQL, Version=2.2.0.0, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7'.
   at Npgsql.EntityFrameworkCore.PostgreSQL.NodaTime.NodaTimePlugin..ctor()
   at Microsoft.EntityFrameworkCore.NodaTimeDbContextOptionsExtensions.UseNodaTime(NpgsqlDbContextOptionsBuilder optionsBuilder) in /home/roji/projects/EFCore.PG/src/EFCore.PG.NodaTime/NodaTimeDbContextOptionsExtensions.cs:line 20
   at Server.Startup.<>c.<ConfigureServices>b__4_2(NpgsqlDbContextOptionsBuilder opts)

These are the versions I'm using:

    <PackageReference Include="NodaTime" Version="2.3.0" />
    <PackageReference Include="Npgsql" Version="4.0.3" />
    <PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="2.2.0-preview1" />
    <PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL.NodaTime" Version="2.1.1" />

What am I doing wrong?

Metadata

Metadata

Labels

No labels
No labels

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions