1

I create a project with dotnet core using webapi template. I'm trying to connect my API with a Oracle database using Citms.EntityFrameworkCore.Oracle package, since the official package isn't free. But every time I start the API, I have the following error on

context.Set<TEntity>();

GenericRepository.cs

public GenericRepository(ApplicationDbContext context)
{
    this.Context = context;
    this.DbSet = context.Set<TEntity>();
}

Error:

System.MissingMethodException: 'Method not found: 'Void Microsoft.EntityFrameworkCore.Storage.Internal.RelationalCommandBuilderFactory..ctor(Microsoft.EntityFrameworkCore.Diagnostics.IDiagnosticsLogger`1<Command>, 

Startup.cs

public void ConfigureServices(IServiceCollection services)
{
    services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);

    services.AddDbContext<ApplicationDbContext>(options =>
    {
        //options.UseMySql(Configuration.GetConnectionString("DefaultConnection"));
        options.UseOracle(@"DATA SOURCE = <CONNECTION_STRING>");
    });

    services.AddSwagger();

    //services.AddScoped<IValuesRepository, ValuesRepository>();
    services.AddScoped<IValueService, ValueService>();

    var corsBuilder = new CorsPolicyBuilder();
    corsBuilder.AllowAnyHeader();
    corsBuilder.AllowAnyMethod();
    corsBuilder.AllowAnyOrigin(); 
    corsBuilder.AllowCredentials();

    services.AddCors(options =>
    {
        options.AddPolicy("SiteCorsPolicy", corsBuilder.Build());
    });
}

1 Answer 1

1

That's a bug in the package you use, it uses internal Entity Framework code that has been modified, and now it no longer works correctly.

See this similar issue for the Pomelo.EntityFrameworkCore.MySql package, where an EF developer responded with:

@AdamDotNet Thanks for reporting this. It is happening because the MySQL provider is making use of EF Core internal code--I filed this issue for that: PomeloFoundation/Pomelo.EntityFrameworkCore.MySql#497

From the EF side, we will discuss in triage whether or not to revert this change to the internal code, but the long term solution is for the provider to stop using internal code.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.