1 и 2 - в миграции прописать
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.Sql(@"CREATE PROC dbo.Execute ...");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.Sql(@"DROP PROC dbo.Execute");
}
3. В своем контексте прописать и вызывать
public class MyDbContext: DbContext
{
public IEnumerable<TEntity> ExecuteSql<TEntity>(string query, dynamic parameters = null, CommandType commandType = CommandType.Text)
{
using (SqlConnection connection = new SqlConnection(Database.GetDbConnection().ConnectionString))
{
connection.Open();
return connection.Query<TEntity>(query, (object)parameters, commandType: commandType);
}
}
}
4. Можно, это же тоже T-SQL