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

The call is ambiguous between the following methods or properties [ Entity framework core ] [ OnModelCreating ] #24355

Closed
MbarkT3STO opened this issue Mar 9, 2021 · 2 comments

Comments

@MbarkT3STO
Copy link

I use ef core, inside y dbcontext class I overrided the onModelCreating method to configure one property in a class to be auto-increment in sql server

My DbContext class:

public class AppDbContext:IdentityDbContext<AppUser>
{
    public AppDbContext(DbContextOptions options) : base(options)
    {
        
    }

    public AppDbContext()
    {
        
    }

    protected override void OnModelCreating(ModelBuilder builder)
    {
        base.OnModelCreating(builder);

        builder.Entity<Service>().Property(service => service.ID).UseIdentityColumn(1, 1);

    }


    public virtual DbSet<AppUser> AppUsers { get; set; }
    public virtual DbSet<Service> Services { get; set; }
}

If you notice that my DbContext class is inherited from IdentityDbContext because I use Identity.

The problem:
The problem is visual studio show me an error

Error:

Severity	Code	Description	Project	File	Line	Suppression State
Error	CS0121	The call is ambiguous between the following methods or properties: 'Microsoft.EntityFrameworkCore.OraclePropertyBuilderExtensions.UseIdentityColumn<TProperty>(Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder<TProperty>, int, int)' and 'Microsoft.EntityFrameworkCore.SqlServerPropertyBuilderExtensions.UseIdentityColumn<TProperty>(Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder<TProperty>, int, int)'

Error Screenshot 1
Error Screenshot 2

Additional info:
I reference another project in my solution this project will play the repository role, and he prepared to work with SqlServer, Oracle and MySQL.

The project I depend on is my own project, and it is open source that is the repository link

Please any help to fix this issue ?

@roji
Copy link
Member

roji commented Mar 9, 2021

Duplicate of #16686

@roji roji marked this as a duplicate of #16686 Mar 9, 2021
@roji
Copy link
Member

roji commented Mar 9, 2021

If you're using multiple providers which have the concept of identity columns, you're going to have to fully-qualify the method call; so instead of calling it like an extension method, call it like a static method:

OraclePropertyBuilderExtensions.UseIdentityColumn(
    builder.Entity<Service>().Property(service => service.ID), 1,1);

@roji roji added the closed-no-further-action The issue is closed and no further action is planned. label Mar 9, 2021
@ajcvickers ajcvickers added closed-duplicate customer-reported and removed closed-no-further-action The issue is closed and no further action is planned. labels Mar 10, 2021
@ajcvickers ajcvickers reopened this Oct 16, 2022
@ajcvickers ajcvickers closed this as not planned Won't fix, can't repro, duplicate, stale Oct 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants