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

IncludeProperties is ambiguous between the Microsoft.EntityFrameworkCore.SqlServerIndexBuilderExtensions.IncludeProperties and the Microsoft.EntityFrameworkCore.NpgsqlIndexBuilderExtensions.IncludeProperties #1334

Closed
xrkolovos opened this issue Apr 3, 2020 · 4 comments

Comments

@xrkolovos
Copy link

We have issue with the use of IncludeProperties, because in our project we have SqlServer and PostgreSql.

The error

The call is ambiguous between the following methods or properties: 
'Microsoft.EntityFrameworkCore.SqlServerIndexBuilderExtensions.IncludeProperties<TEntity>
(Microsoft.EntityFrameworkCore.Metadata.Builders.IndexBuilder<TEntity>, System.Linq.Expressions.Expression<System.Func<TEntity, object>>)' 
and 
'Microsoft.EntityFrameworkCore.NpgsqlIndexBuilderExtensions.IncludeProperties<TEntity>
(Microsoft.EntityFrameworkCore.Metadata.Builders.IndexBuilder<TEntity>, System.Linq.Expressions.Expression<System.Func<TEntity, object>>)'	

@roji
Copy link
Member

roji commented Apr 3, 2020

Yes, this is a known wrinkle. The workaround is to call the desired method explicitly, not as an extension method.

Instead of:

modelBuilder.Entity<Blog>().HasIndex(f => f.Name).IncludeProperties(f => f.Description);

Use:

NpgsqlIndexBuilderExtensions.IncludeProperties(
    modelBuilder.Entity<Blog>().HasIndex(f => f.Name),
    f => f.Description);

This isn't ideal, but the number of projects using multiple providers that support the same extensions is quite low.

@xrkolovos
Copy link
Author

Hello,

This issue is worst in .net5.

There is code using IncludeProperties in autogenerated code in the *Designer.cs file.

You must change the name of this method.

@tdolgyras
Copy link

How can we reopen this?

@xrkolovos
Copy link
Author

Before it used
.HasAnnotation("SqlServer:Include",..

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

3 participants