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.
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.
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();