i created procedure for each db types that supported by my application. and added into their migration files.
i can call stored procedure MSSQL like this two type in my code first app one
worker.StoredProcedures.ExecuteWithStoreProcedure("sp_userVirman @ResourceUserID,@targetUserID",
new SqlParameter("ResourceUserID",DbType.Int64) { Value = 1 },
new SqlParameter("targetUserID", DbType.Int64) { Value = 2 });
two
worker.StoredProcedures.ExecuteWithStoreProcedure(string.Format("sp_userVirman {0},{1}", 1, 2));
but when the db provider change to mysql, it gives error.
An unhandled exception of type 'MySql.Data.MySqlClient.MySqlException' occurred in EntityFramework.dll Additional information: Only MySqlParameter objects may be stored
and also providers can change oracle postgresql mysql etc.
how can solve this problem?
i dont want to use if provider== mssql if provider==mysql etc...
this is my main function
public void ExecuteWithStoreProcedure(string query, params object[] parameters)
{
_dbContext.Database.ExecuteSqlCommand(query, parameters);
}