missing stored procs when scaffolding mysql using EF Core on .net core and pomelo drivers

.net-core entity-framework-core mysql stored-procedures

Question

I'm trying to use Scaffolding in EFCore against a mysql database where the generated code will be run on Linux CentOS (NetCoreApp framework). I'm developing on Windows with VS2015 Update3.

Tables are successfully reverse engineered, but stored procedures are not included. Without stored procedures, I'm afraid we'll have to ditch EFCore.


  • Does scaffolding in EFCore against mysql support reverse engineering stored procedures?
  • Using any combination of drivers?
  • Assuming this functionality turns out to be absent from EFCore currently, do you know of any solution, paid or unpaid, to accomplish this - reverse engineer existing mysql database to be used in netcoreapp on CentOS?

As a sample case, I started with a mysql database with a single table and a parameterless stored proc. I think I'm using the latest EFCore and Pomelo drivers as shown in project.json below...

{
  "version": "1.1.0-*",
  "buildOptions": {
    "emitEntryPoint": true
  },

  "tools": {
    "Microsoft.EntityFrameworkCore.Tools": "1.1.0-preview4-final"
  },

  "dependencies": {
    "Microsoft.EntityFrameworkCore.Design": "1.1.0",
    "Pomelo.EntityFrameworkCore.MySql": "1.1.1-prerelease-10011",
    "Pomelo.Data.MySql": "1.0.0",
    "Pomelo.EntityFrameworkCore.MySql.Design": "1.1.1-prerelease-10011",
    "Microsoft.EntityFrameworkCore.Tools": "1.1.0-preview4-final"
  },

  "frameworks": {
    "netcoreapp1.1": {
      "dependencies": {
        "Microsoft.NETCore.App": {
          "type": "platform",
          "version": "1.1.0-*"
        }
      }
    }
  }
}

And after doing the dotnet restore use the following to invoke scaffolding...

Scaffold-DbContext "server=localhost;user id=root;password=;database=simpledb" Pomelo.EntityFrameworkCore.MySql -OutputDir Models -force

After running the scaffolding, in both my real case and in the simple test case, the generated code only contains tables, and does not contain stored procedures.

1
1
1/12/2017 2:43:43 PM

Popular Answer

There is a Known issue with Pomelo and latest version of Entity Framework.

It is working for me with this configuration:

Microsoft.EntityFrameWorkCore 2.0.3
Microsoft.EntityFrameworkCore.Tools 2.0.3
Pomelo.EntityFrameworkCore.MySql 2.0.1

To call the stored procedure in MySql you can use something like:

var values = _context.Test.FromSql("call test_proc2(0)").ToList();
0
6/1/2018 7:26:10 AM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow