efcore.pg icon indicating copy to clipboard operation
efcore.pg copied to clipboard

Method 'Create' does not have an implementation in .Net Core 3

Open netbidev opened this issue 7 years ago • 4 comments

I'm trying create model from existing database and I have error:

Method 'Create' in type 'Npgsql.EntityFrameworkCore.PostgreSQL.Scaffolding.Internal.NpgsqlDatabaseModelFactory' from assembly 'Npgsql.EntityFrameworkCore.PostgreSQL, Version=3.0.0.0, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7' does not have an implementation.

Table:

CREATE TABLE public.test
(
    id serial NOT NULL,
    name text COLLATE pg_catalog."default" NOT NULL,
    created timestamp with time zone NOT NULL DEFAULT now(),
    CONSTRAINT test_pkey PRIMARY KEY (id)
)
TABLESPACE pg_default;

Npgsql.EntityFrameworkCore.PostgreSQL version 3.0.0-preview1

netbidev avatar Sep 21 '19 18:09 netbidev

You're likely trying to mix different versions of the Npgsql provider and EF Core itself. Make sure all versions are aligned, and if the error persists, please post your csproj.

roji avatar Sep 22 '19 01:09 roji

csproj here

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>netcoreapp3.0</TargetFramework>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.0.0-rc1.19456.14">
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
      <PrivateAssets>all</PrivateAssets>
    </PackageReference>
    <PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="3.0.0-preview1" />
  </ItemGroup>
</Project>

Result of command "dotnet ef dbcontext scaffold --version" is 3.0.0-rc1.19456.14

netbidev avatar Sep 22 '19 06:09 netbidev

You're trying to use Npgsql.EntityFrameworkCore.PostgreSQL 3.0.0-preview1 with Microsoft.EntityFrameworkCore.Design 3.0.0-rc1... Change both to use preview9 (there's no rc1 of the Npgsql provider, we'll publish the release directly early next week).

roji avatar Sep 22 '19 10:09 roji

Worked for me! Thanks @franciscojunior.

Is it possible to make the error message more informative? Something like:

Version mismatch between Npgsql.EntityFrameworkCore.PostgreSQL and Microsoft.EntityFrameworkCore.Design.

PeterDraex avatar Oct 13 '21 15:10 PeterDraex